Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/fixtures/development/001_create_base_work_item_types.rb5
-rw-r--r--db/fixtures/production/003_create_base_work_item_types.rb5
-rw-r--r--db/migrate/20210831203408_upsert_base_work_item_types.rb31
-rw-r--r--db/migrate/20210901065504_add_index_on_name_and_id_to_public_groups.rb17
-rw-r--r--db/schema_migrations/202108312034081
-rw-r--r--db/schema_migrations/202109010655041
-rw-r--r--db/structure.sql2
7 files changed, 62 insertions, 0 deletions
diff --git a/db/fixtures/development/001_create_base_work_item_types.rb b/db/fixtures/development/001_create_base_work_item_types.rb
new file mode 100644
index 00000000000..7a541ca20b0
--- /dev/null
+++ b/db/fixtures/development/001_create_base_work_item_types.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+Gitlab::Seeder.quiet do
+ Gitlab::DatabaseImporters::WorkItems::BaseTypeImporter.import
+end
diff --git a/db/fixtures/production/003_create_base_work_item_types.rb b/db/fixtures/production/003_create_base_work_item_types.rb
new file mode 100644
index 00000000000..7a541ca20b0
--- /dev/null
+++ b/db/fixtures/production/003_create_base_work_item_types.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+Gitlab::Seeder.quiet do
+ Gitlab::DatabaseImporters::WorkItems::BaseTypeImporter.import
+end
diff --git a/db/migrate/20210831203408_upsert_base_work_item_types.rb b/db/migrate/20210831203408_upsert_base_work_item_types.rb
new file mode 100644
index 00000000000..314412d8d3d
--- /dev/null
+++ b/db/migrate/20210831203408_upsert_base_work_item_types.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class UpsertBaseWorkItemTypes < ActiveRecord::Migration[6.1]
+ module WorkItem
+ class Type < ActiveRecord::Base
+ self.table_name = 'work_item_types'
+
+ enum base_type: {
+ issue: 0,
+ incident: 1,
+ test_case: 2,
+ requirement: 3
+ }
+ end
+ end
+
+ def up
+ # upsert default types
+ WorkItem::Type.find_or_create_by(name: 'Issue', namespace_id: nil, base_type: :issue, icon_name: 'issue-type-issue')
+ WorkItem::Type.find_or_create_by(name: 'Incident', namespace_id: nil, base_type: :incident, icon_name: 'issue-type-incident')
+ WorkItem::Type.find_or_create_by(name: 'Test Case', namespace_id: nil, base_type: :test_case, icon_name: 'issue-type-test-case')
+ WorkItem::Type.find_or_create_by(name: 'Requirement', namespace_id: nil, base_type: :requirement, icon_name: 'issue-type-requirements')
+ end
+
+ def down
+ # We expect this table to be empty at the point of the up migration,
+ # however there is a remote possibility that issues could already be
+ # using one of these types, with a tight foreign constraint.
+ # Therefore we will not attempt to remove any data.
+ end
+end
diff --git a/db/migrate/20210901065504_add_index_on_name_and_id_to_public_groups.rb b/db/migrate/20210901065504_add_index_on_name_and_id_to_public_groups.rb
new file mode 100644
index 00000000000..77b9e5297a7
--- /dev/null
+++ b/db/migrate/20210901065504_add_index_on_name_and_id_to_public_groups.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexOnNameAndIdToPublicGroups < Gitlab::Database::Migration[1.0]
+ INDEX_NAME = 'index_namespaces_public_groups_name_id'
+ PUBLIC_VISIBILITY_LEVEL = 20
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :namespaces, [:name, :id], name: INDEX_NAME,
+ where: "type = 'Group' AND visibility_level = #{PUBLIC_VISIBILITY_LEVEL}"
+ end
+
+ def down
+ remove_concurrent_index_by_name :namespaces, INDEX_NAME
+ end
+end
diff --git a/db/schema_migrations/20210831203408 b/db/schema_migrations/20210831203408
new file mode 100644
index 00000000000..6ab3f810e57
--- /dev/null
+++ b/db/schema_migrations/20210831203408
@@ -0,0 +1 @@
+50a06a2a57ed26c25af53d3d7f6f5ef73efde8a23a36c5f825af56b4d0c4c3f6 \ No newline at end of file
diff --git a/db/schema_migrations/20210901065504 b/db/schema_migrations/20210901065504
new file mode 100644
index 00000000000..f62e6ce1272
--- /dev/null
+++ b/db/schema_migrations/20210901065504
@@ -0,0 +1 @@
+9724a5fc1703418f9b1ea1d5375fc3b01834b30e5ff16c60537db5cb00bc210a \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index f149a299c45..d6b561419ed 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -25691,6 +25691,8 @@ CREATE INDEX index_namespaces_on_traversal_ids ON namespaces USING gin (traversa
CREATE INDEX index_namespaces_on_type_and_id_partial ON namespaces USING btree (type, id) WHERE (type IS NOT NULL);
+CREATE INDEX index_namespaces_public_groups_name_id ON namespaces USING btree (name, id) WHERE (((type)::text = 'Group'::text) AND (visibility_level = 20));
+
CREATE INDEX index_non_requested_project_members_on_source_id_and_type ON members USING btree (source_id, source_type) WHERE ((requested_at IS NULL) AND ((type)::text = 'ProjectMember'::text));
CREATE UNIQUE INDEX index_note_diff_files_on_diff_note_id ON note_diff_files USING btree (diff_note_id);