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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-27 12:09:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-27 12:09:51 +0300
commit39fa1b598749be0aad699032bbf31450b3ff0098 (patch)
tree15a4c28989d58f9315e58458a3a494ff8cfc1525 /db
parenta59d305223365cb31bb670f134383d6ff316a13e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20200304023245_add_sprint_to_issues.rb20
-rw-r--r--db/migrate/20200304023851_add_sprint_to_merge_requests.rb20
-rw-r--r--db/migrate/20200304024025_add_sprint_id_index_to_issues.rb21
-rw-r--r--db/migrate/20200304024042_add_sprint_id_index_to_merge_requests.rb21
-rw-r--r--db/migrate/20200402001106_add_cluster_type_index_to_clusters.rb19
-rw-r--r--db/migrate/20200420201933_add_check_constraint_to_sprint_must_belong_to_project_or_group.rb19
-rw-r--r--db/structure.sql25
7 files changed, 143 insertions, 2 deletions
diff --git a/db/migrate/20200304023245_add_sprint_to_issues.rb b/db/migrate/20200304023245_add_sprint_to_issues.rb
new file mode 100644
index 00000000000..c8bc5258ffd
--- /dev/null
+++ b/db/migrate/20200304023245_add_sprint_to_issues.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddSprintToIssues < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ # index will be added in another migration with `add_concurrent_index`
+ add_column :issues, :sprint_id, :bigint
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :issues, :sprint_id
+ end
+ end
+end
diff --git a/db/migrate/20200304023851_add_sprint_to_merge_requests.rb b/db/migrate/20200304023851_add_sprint_to_merge_requests.rb
new file mode 100644
index 00000000000..e294abe66cd
--- /dev/null
+++ b/db/migrate/20200304023851_add_sprint_to_merge_requests.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddSprintToMergeRequests < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ # index will be added in another migration with `add_concurrent_index`
+ add_column :merge_requests, :sprint_id, :bigint
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :merge_requests, :sprint_id
+ end
+ end
+end
diff --git a/db/migrate/20200304024025_add_sprint_id_index_to_issues.rb b/db/migrate/20200304024025_add_sprint_id_index_to_issues.rb
new file mode 100644
index 00000000000..1782841f82e
--- /dev/null
+++ b/db/migrate/20200304024025_add_sprint_id_index_to_issues.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddSprintIdIndexToIssues < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :issues, :sprint_id
+ add_concurrent_foreign_key :issues, :sprints, column: :sprint_id
+ end
+
+ def down
+ with_lock_retries do # rubocop:disable Migration/WithLockRetriesWithoutDdlTransaction
+ remove_foreign_key :issues, column: :sprint_id
+ end
+ remove_concurrent_index :issues, :sprint_id
+ end
+end
diff --git a/db/migrate/20200304024042_add_sprint_id_index_to_merge_requests.rb b/db/migrate/20200304024042_add_sprint_id_index_to_merge_requests.rb
new file mode 100644
index 00000000000..44fbab4b96a
--- /dev/null
+++ b/db/migrate/20200304024042_add_sprint_id_index_to_merge_requests.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddSprintIdIndexToMergeRequests < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :merge_requests, :sprint_id
+ add_concurrent_foreign_key :merge_requests, :sprints, column: :sprint_id
+ end
+
+ def down
+ with_lock_retries do # rubocop:disable Migration/WithLockRetriesWithoutDdlTransaction
+ remove_foreign_key :merge_requests, column: :sprint_id
+ end
+ remove_concurrent_index :merge_requests, :sprint_id
+ end
+end
diff --git a/db/migrate/20200402001106_add_cluster_type_index_to_clusters.rb b/db/migrate/20200402001106_add_cluster_type_index_to_clusters.rb
new file mode 100644
index 00000000000..b328b8681c1
--- /dev/null
+++ b/db/migrate/20200402001106_add_cluster_type_index_to_clusters.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddClusterTypeIndexToClusters < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+ INDEX_NAME = 'index_clusters_on_enabled_cluster_type_id_and_created_at'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :clusters, [:enabled, :cluster_type, :id, :created_at], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :clusters, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20200420201933_add_check_constraint_to_sprint_must_belong_to_project_or_group.rb b/db/migrate/20200420201933_add_check_constraint_to_sprint_must_belong_to_project_or_group.rb
new file mode 100644
index 00000000000..9962eab95e3
--- /dev/null
+++ b/db/migrate/20200420201933_add_check_constraint_to_sprint_must_belong_to_project_or_group.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddCheckConstraintToSprintMustBelongToProjectOrGroup < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ CONSTRAINT_NAME = 'sprints_must_belong_to_project_or_group'
+
+ def up
+ add_check_constraint :sprints, '(project_id != NULL AND group_id IS NULL) OR (group_id != NULL AND project_id IS NULL)', CONSTRAINT_NAME
+ end
+
+ def down
+ remove_check_constraint :sprints, CONSTRAINT_NAME
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index c61f775da5e..77eeabfd53d 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -3357,7 +3357,8 @@ CREATE TABLE public.issues (
duplicated_to_id integer,
promoted_to_epic_id integer,
health_status smallint,
- external_key character varying(255)
+ external_key character varying(255),
+ sprint_id bigint
);
CREATE SEQUENCE public.issues_id_seq
@@ -3932,7 +3933,8 @@ CREATE TABLE public.merge_requests (
allow_maintainer_to_push boolean,
state_id smallint DEFAULT 1 NOT NULL,
rebase_jid character varying,
- squash_commit_sha bytea
+ squash_commit_sha bytea,
+ sprint_id bigint
);
CREATE TABLE public.merge_requests_closing_issues (
@@ -6106,6 +6108,7 @@ CREATE TABLE public.sprints (
title_html text,
description text,
description_html text,
+ CONSTRAINT sprints_must_belong_to_project_or_group CHECK ((((project_id <> NULL::bigint) AND (group_id IS NULL)) OR ((group_id <> NULL::bigint) AND (project_id IS NULL)))),
CONSTRAINT sprints_title CHECK ((char_length(title) <= 255))
);
@@ -9208,6 +9211,8 @@ CREATE INDEX index_clusters_kubernetes_namespaces_on_project_id ON public.cluste
CREATE INDEX index_clusters_on_enabled_and_provider_type_and_id ON public.clusters USING btree (enabled, provider_type, id);
+CREATE INDEX index_clusters_on_enabled_cluster_type_id_and_created_at ON public.clusters USING btree (enabled, cluster_type, id, created_at);
+
CREATE INDEX index_clusters_on_management_project_id ON public.clusters USING btree (management_project_id) WHERE (management_project_id IS NOT NULL);
CREATE INDEX index_clusters_on_user_id ON public.clusters USING btree (user_id);
@@ -9598,6 +9603,8 @@ CREATE INDEX index_issues_on_promoted_to_epic_id ON public.issues USING btree (p
CREATE INDEX index_issues_on_relative_position ON public.issues USING btree (relative_position);
+CREATE INDEX index_issues_on_sprint_id ON public.issues USING btree (sprint_id);
+
CREATE INDEX index_issues_on_title_trigram ON public.issues USING gin (title public.gin_trgm_ops);
CREATE INDEX index_issues_on_updated_at ON public.issues USING btree (updated_at);
@@ -9760,6 +9767,8 @@ CREATE INDEX index_merge_requests_on_source_branch ON public.merge_requests USIN
CREATE INDEX index_merge_requests_on_source_project_id_and_source_branch ON public.merge_requests USING btree (source_project_id, source_branch);
+CREATE INDEX index_merge_requests_on_sprint_id ON public.merge_requests USING btree (sprint_id);
+
CREATE INDEX index_merge_requests_on_target_branch ON public.merge_requests USING btree (target_branch);
CREATE UNIQUE INDEX index_merge_requests_on_target_project_id_and_iid ON public.merge_requests USING btree (target_project_id, iid);
@@ -10849,6 +10858,9 @@ ALTER TABLE ONLY public.push_event_payloads
ALTER TABLE ONLY public.ci_builds
ADD CONSTRAINT fk_3a9eaa254d FOREIGN KEY (stage_id) REFERENCES public.ci_stages(id) ON DELETE CASCADE;
+ALTER TABLE ONLY public.issues
+ ADD CONSTRAINT fk_3b8c72ea56 FOREIGN KEY (sprint_id) REFERENCES public.sprints(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY public.epics
ADD CONSTRAINT fk_3c1fd1cccc FOREIGN KEY (due_date_sourcing_milestone_id) REFERENCES public.milestones(id) ON DELETE SET NULL;
@@ -10966,6 +10978,9 @@ ALTER TABLE ONLY public.vulnerabilities
ALTER TABLE ONLY public.labels
ADD CONSTRAINT fk_7de4989a69 FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
+ALTER TABLE ONLY public.merge_requests
+ ADD CONSTRAINT fk_7e85395a64 FOREIGN KEY (sprint_id) REFERENCES public.sprints(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY public.merge_request_metrics
ADD CONSTRAINT fk_7f28d925f3 FOREIGN KEY (merged_by_id) REFERENCES public.users(id) ON DELETE SET NULL;
@@ -13285,6 +13300,10 @@ COPY "schema_migrations" (version) FROM STDIN;
20200303055348
20200303074328
20200303181648
+20200304023245
+20200304023851
+20200304024025
+20200304024042
20200304085423
20200304090155
20200304121828
@@ -13394,6 +13413,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200401091051
20200401095430
20200401211005
+20200402001106
20200402123926
20200402124802
20200402135250
@@ -13457,6 +13477,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200420172113
20200420172752
20200420172927
+20200420201933
20200421233150
20200423075720
20200423080334