diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-24 00:10:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-24 00:10:44 +0300 |
commit | 5e450e9022861d03048cc733c20585ad0891f5aa (patch) | |
tree | 6a5eb2f639fe66b3fa52008e2f99c31e1ce2d60b /db | |
parent | c37dd28c4afd33fee46cff8ddfdada8a3f54564c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
19 files changed, 225 insertions, 39 deletions
diff --git a/db/migrate/20210127152613_add_iterations_cadence_date_range_constraint.rb b/db/migrate/20210127152613_add_iterations_cadence_date_range_constraint.rb new file mode 100644 index 00000000000..95ecd167076 --- /dev/null +++ b/db/migrate/20210127152613_add_iterations_cadence_date_range_constraint.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +class AddIterationsCadenceDateRangeConstraint < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + execute <<~SQL + ALTER TABLE sprints + ADD CONSTRAINT iteration_start_and_due_date_iterations_cadence_id_constraint + EXCLUDE USING gist + ( iterations_cadence_id WITH =, + daterange(start_date, due_date, '[]') WITH && + ) + WHERE (group_id IS NOT NULL) + SQL + end + end + + def down + with_lock_retries do + execute <<~SQL + ALTER TABLE sprints + DROP CONSTRAINT IF EXISTS iteration_start_and_due_date_iterations_cadence_id_constraint + SQL + end + end +end diff --git a/db/migrate/20210127202613_remove_iteration_group_date_range_constraint.rb b/db/migrate/20210127202613_remove_iteration_group_date_range_constraint.rb new file mode 100644 index 00000000000..e6c5eb1b411 --- /dev/null +++ b/db/migrate/20210127202613_remove_iteration_group_date_range_constraint.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +class RemoveIterationGroupDateRangeConstraint < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + execute <<~SQL + ALTER TABLE sprints + DROP CONSTRAINT IF EXISTS iteration_start_and_due_daterange_group_id_constraint + SQL + end + end + + def down + with_lock_retries do + execute <<~SQL + ALTER TABLE sprints + ADD CONSTRAINT iteration_start_and_due_daterange_group_id_constraint + EXCLUDE USING gist + ( group_id WITH =, + daterange(start_date, due_date, '[]') WITH && + ) + WHERE (group_id IS NOT NULL) + SQL + end + end +end diff --git a/db/migrate/20210214201118_add_delayed_project_removal_to_namespace_settings.rb b/db/migrate/20210214201118_add_delayed_project_removal_to_namespace_settings.rb new file mode 100644 index 00000000000..1c6e0b0c27c --- /dev/null +++ b/db/migrate/20210214201118_add_delayed_project_removal_to_namespace_settings.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddDelayedProjectRemovalToNamespaceSettings < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :namespace_settings, :delayed_project_removal, :boolean, default: false, null: false + end +end diff --git a/db/migrate/20210214205155_add_index_to_namespaces_delayed_project_removal.rb b/db/migrate/20210214205155_add_index_to_namespaces_delayed_project_removal.rb new file mode 100644 index 00000000000..8d09a5c9269 --- /dev/null +++ b/db/migrate/20210214205155_add_index_to_namespaces_delayed_project_removal.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddIndexToNamespacesDelayedProjectRemoval < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'tmp_idx_on_namespaces_delayed_project_removal' + + disable_ddl_transaction! + + def up + add_concurrent_index :namespaces, :id, name: INDEX_NAME, where: 'delayed_project_removal = TRUE' + end + + def down + remove_concurrent_index_by_name :namespaces, INDEX_NAME + end +end diff --git a/db/migrate/20210218144056_add_sprints_start_date_not_null_check_constraint.rb b/db/migrate/20210218144056_add_sprints_start_date_not_null_check_constraint.rb new file mode 100644 index 00000000000..243080f49b2 --- /dev/null +++ b/db/migrate/20210218144056_add_sprints_start_date_not_null_check_constraint.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddSprintsStartDateNotNullCheckConstraint < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_not_null_constraint(:sprints, :start_date, validate: false) + end + + def down + remove_not_null_constraint(:sprints, :start_date) + end +end diff --git a/db/migrate/20210218144656_add_sprints_due_date_not_null_check_constraint.rb b/db/migrate/20210218144656_add_sprints_due_date_not_null_check_constraint.rb new file mode 100644 index 00000000000..9f3ed6fd13a --- /dev/null +++ b/db/migrate/20210218144656_add_sprints_due_date_not_null_check_constraint.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddSprintsDueDateNotNullCheckConstraint < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_not_null_constraint(:sprints, :due_date, validate: false) + end + + def down + remove_not_null_constraint(:sprints, :due_date) + end +end diff --git a/db/post_migrate/20210215095328_migrate_delayed_project_removal_from_namespaces_to_namespace_settings.rb b/db/post_migrate/20210215095328_migrate_delayed_project_removal_from_namespaces_to_namespace_settings.rb new file mode 100644 index 00000000000..12e156d3b8a --- /dev/null +++ b/db/post_migrate/20210215095328_migrate_delayed_project_removal_from_namespaces_to_namespace_settings.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class MigrateDelayedProjectRemovalFromNamespacesToNamespaceSettings < ActiveRecord::Migration[6.0] + DOWNTIME = false + + class Namespace < ActiveRecord::Base + self.table_name = 'namespaces' + + include ::EachBatch + end + + def up + Namespace.select(:id).where(delayed_project_removal: true).each_batch do |batch| + values = batch.map { |record| "(#{record.id}, TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)" } + + execute <<-EOF.strip_heredoc + INSERT INTO namespace_settings (namespace_id, delayed_project_removal, created_at, updated_at) + VALUES #{values.join(', ')} + ON CONFLICT (namespace_id) DO UPDATE + SET delayed_project_removal = TRUE + EOF + end + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20210222185538_remove_backup_labels_foreign_keys.rb b/db/post_migrate/20210222185538_remove_backup_labels_foreign_keys.rb new file mode 100644 index 00000000000..614ec4875d6 --- /dev/null +++ b/db/post_migrate/20210222185538_remove_backup_labels_foreign_keys.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class RemoveBackupLabelsForeignKeys < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + with_lock_retries do + remove_foreign_key_if_exists(:backup_labels, :projects) + remove_foreign_key_if_exists(:backup_labels, :namespaces) + end + end + + def down + add_concurrent_foreign_key(:backup_labels, :projects, column: :project_id, on_delete: :cascade) + add_concurrent_foreign_key(:backup_labels, :namespaces, column: :group_id, on_delete: :cascade) + end +end diff --git a/db/post_migrate/20210222192144_remove_backup_labels_table.rb b/db/post_migrate/20210222192144_remove_backup_labels_table.rb new file mode 100644 index 00000000000..1208c3c970f --- /dev/null +++ b/db/post_migrate/20210222192144_remove_backup_labels_table.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +class RemoveBackupLabelsTable < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def up + drop_table :backup_labels + end + + def down + create_table :backup_labels, id: false do |t| + t.integer :id, null: false + t.string :title + t.string :color + t.integer :project_id + t.timestamps null: true # rubocop:disable Migration/Timestamps + t.boolean :template, default: false + t.string :description + t.text :description_html + t.string :type + t.integer :group_id + t.integer :cached_markdown_version + t.integer :restore_action + t.string :new_title + end + + execute 'ALTER TABLE backup_labels ADD PRIMARY KEY (id)' + + add_index :backup_labels, [:group_id, :project_id, :title], name: 'backup_labels_group_id_project_id_title_idx', unique: true + add_index :backup_labels, [:group_id, :title], where: 'project_id = NULL::integer', name: 'backup_labels_group_id_title_idx' + add_index :backup_labels, :project_id, name: 'backup_labels_project_id_idx' + add_index :backup_labels, :template, name: 'backup_labels_template_idx', where: 'template' + add_index :backup_labels, :title, name: 'backup_labels_title_idx' + add_index :backup_labels, [:type, :project_id], name: 'backup_labels_type_project_id_idx' + end +end diff --git a/db/schema_migrations/20210127152613 b/db/schema_migrations/20210127152613 new file mode 100644 index 00000000000..f5d42ea2bc5 --- /dev/null +++ b/db/schema_migrations/20210127152613 @@ -0,0 +1 @@ +32f636ffad4d2c6a002129d6e3eaeaf5d8f420dcc1273665129dc4d23f2e0dbe
\ No newline at end of file diff --git a/db/schema_migrations/20210127202613 b/db/schema_migrations/20210127202613 new file mode 100644 index 00000000000..42d38d4c1d7 --- /dev/null +++ b/db/schema_migrations/20210127202613 @@ -0,0 +1 @@ +951f46f88c1b07505e0b560e802a8bd701db7d379342d97b0bff3ad90e81fb02
\ No newline at end of file diff --git a/db/schema_migrations/20210214201118 b/db/schema_migrations/20210214201118 new file mode 100644 index 00000000000..9551d2ddf50 --- /dev/null +++ b/db/schema_migrations/20210214201118 @@ -0,0 +1 @@ +8c1da1c7edba16993da93d9075ad2a3624b8c12ccf73a241e1a166014a99e254
\ No newline at end of file diff --git a/db/schema_migrations/20210214205155 b/db/schema_migrations/20210214205155 new file mode 100644 index 00000000000..583d7ca1167 --- /dev/null +++ b/db/schema_migrations/20210214205155 @@ -0,0 +1 @@ +7678d97de752e7a9a571d80febc74eb44c699c7b1967690d9a2391036caea5d2
\ No newline at end of file diff --git a/db/schema_migrations/20210215095328 b/db/schema_migrations/20210215095328 new file mode 100644 index 00000000000..b360aaf4ad8 --- /dev/null +++ b/db/schema_migrations/20210215095328 @@ -0,0 +1 @@ +25820a3d060826a082565f12a3ac96deafbbde750f5756d71e34d14801ec6148
\ No newline at end of file diff --git a/db/schema_migrations/20210218144056 b/db/schema_migrations/20210218144056 new file mode 100644 index 00000000000..566015ad8be --- /dev/null +++ b/db/schema_migrations/20210218144056 @@ -0,0 +1 @@ +545747e86481c74832a6df55764ab97ecfefc4446df9cc2366a8ce9d9c400ea4
\ No newline at end of file diff --git a/db/schema_migrations/20210218144656 b/db/schema_migrations/20210218144656 new file mode 100644 index 00000000000..622877a279e --- /dev/null +++ b/db/schema_migrations/20210218144656 @@ -0,0 +1 @@ +91969bfc791cd7bc78b940aa6fed345b13a3186db0b89828428b798aa4f7949e
\ No newline at end of file diff --git a/db/schema_migrations/20210222185538 b/db/schema_migrations/20210222185538 new file mode 100644 index 00000000000..20229c9be20 --- /dev/null +++ b/db/schema_migrations/20210222185538 @@ -0,0 +1 @@ +0bccf1ff356a4b9c08d472e8b63070b497f331c2dfaded1bdb2cf01860df8903
\ No newline at end of file diff --git a/db/schema_migrations/20210222192144 b/db/schema_migrations/20210222192144 new file mode 100644 index 00000000000..b53b1668a1f --- /dev/null +++ b/db/schema_migrations/20210222192144 @@ -0,0 +1 @@ +b2508d46edbfbba24df65731f6e285886acbb6352a900dd1c6a985a686252ef0
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 87e6d3e6cbb..6097ff0565b 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -9747,23 +9747,6 @@ CREATE SEQUENCE background_migration_jobs_id_seq ALTER SEQUENCE background_migration_jobs_id_seq OWNED BY background_migration_jobs.id; -CREATE TABLE backup_labels ( - id integer NOT NULL, - title character varying, - color character varying, - project_id integer, - created_at timestamp without time zone, - updated_at timestamp without time zone, - template boolean DEFAULT false, - description character varying, - description_html text, - type character varying, - group_id integer, - cached_markdown_version integer, - restore_action integer, - new_title character varying -); - CREATE TABLE badges ( id integer NOT NULL, link_url character varying NOT NULL, @@ -14370,6 +14353,7 @@ CREATE TABLE namespace_settings ( allow_mfa_for_subgroups boolean DEFAULT true NOT NULL, default_branch_name text, repository_read_only boolean DEFAULT false NOT NULL, + delayed_project_removal boolean DEFAULT false NOT NULL, CONSTRAINT check_0ba93c78c7 CHECK ((char_length(default_branch_name) <= 255)) ); @@ -19823,9 +19807,6 @@ ALTER TABLE ONLY aws_roles ALTER TABLE ONLY background_migration_jobs ADD CONSTRAINT background_migration_jobs_pkey PRIMARY KEY (id); -ALTER TABLE ONLY backup_labels - ADD CONSTRAINT backup_labels_pkey PRIMARY KEY (id); - ALTER TABLE ONLY badges ADD CONSTRAINT badges_pkey PRIMARY KEY (id); @@ -19889,9 +19870,15 @@ ALTER TABLE ONLY chat_teams ALTER TABLE vulnerability_scanners ADD CONSTRAINT check_37608c9db5 CHECK ((char_length(vendor) <= 255)) NOT VALID; +ALTER TABLE sprints + ADD CONSTRAINT check_ccd8a1eae0 CHECK ((start_date IS NOT NULL)) NOT VALID; + ALTER TABLE group_import_states ADD CONSTRAINT check_cda75c7c3f CHECK ((user_id IS NOT NULL)) NOT VALID; +ALTER TABLE sprints + ADD CONSTRAINT check_df3816aed7 CHECK ((due_date IS NOT NULL)) NOT VALID; + ALTER TABLE ONLY ci_build_needs ADD CONSTRAINT ci_build_needs_pkey PRIMARY KEY (id); @@ -20400,7 +20387,7 @@ ALTER TABLE ONLY issues_self_managed_prometheus_alert_events ADD CONSTRAINT issues_self_managed_prometheus_alert_events_pkey PRIMARY KEY (issue_id, self_managed_prometheus_alert_event_id); ALTER TABLE ONLY sprints - ADD CONSTRAINT iteration_start_and_due_daterange_group_id_constraint EXCLUDE USING gist (group_id WITH =, daterange(start_date, due_date, '[]'::text) WITH &&) WHERE ((group_id IS NOT NULL)); + ADD CONSTRAINT iteration_start_and_due_date_iterations_cadence_id_constraint EXCLUDE USING gist (iterations_cadence_id WITH =, daterange(start_date, due_date, '[]'::text) WITH &&) WHERE ((group_id IS NOT NULL)); ALTER TABLE ONLY sprints ADD CONSTRAINT iteration_start_and_due_daterange_project_id_constraint EXCLUDE USING gist (project_id WITH =, daterange(start_date, due_date, '[]'::text) WITH &&) WHERE ((project_id IS NOT NULL)); @@ -21271,18 +21258,6 @@ CREATE UNIQUE INDEX any_approver_project_rule_type_unique_index ON approval_proj CREATE INDEX approval_mr_rule_index_merge_request_id ON approval_merge_request_rules USING btree (merge_request_id); -CREATE UNIQUE INDEX backup_labels_group_id_project_id_title_idx ON backup_labels USING btree (group_id, project_id, title); - -CREATE INDEX backup_labels_group_id_title_idx ON backup_labels USING btree (group_id, title) WHERE (project_id = NULL::integer); - -CREATE INDEX backup_labels_project_id_idx ON backup_labels USING btree (project_id); - -CREATE INDEX backup_labels_template_idx ON backup_labels USING btree (template) WHERE template; - -CREATE INDEX backup_labels_title_idx ON backup_labels USING btree (title); - -CREATE INDEX backup_labels_type_project_id_idx ON backup_labels USING btree (type, project_id); - CREATE UNIQUE INDEX bulk_import_trackers_uniq_relation_by_entity ON bulk_import_trackers USING btree (bulk_import_entity_id, relation); CREATE INDEX ci_builds_gitlab_monitor_metrics ON ci_builds USING btree (status, created_at, project_id) WHERE ((type)::text = 'Ci::Build'::text); @@ -23869,6 +23844,8 @@ CREATE UNIQUE INDEX term_agreements_unique_index ON term_agreements USING btree CREATE INDEX tmp_idx_deduplicate_vulnerability_occurrences ON vulnerability_occurrences USING btree (project_id, report_type, location_fingerprint, primary_identifier_id, id); +CREATE INDEX tmp_idx_on_namespaces_delayed_project_removal ON namespaces USING btree (id) WHERE (delayed_project_removal = true); + CREATE INDEX tmp_index_on_security_findings_scan_id ON security_findings USING btree (scan_id) WHERE (uuid IS NULL); CREATE INDEX tmp_index_on_vulnerabilities_non_dismissed ON vulnerabilities USING btree (id) WHERE (state <> 2); @@ -24461,9 +24438,6 @@ ALTER TABLE ONLY vulnerabilities ALTER TABLE ONLY labels ADD CONSTRAINT fk_7de4989a69 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; -ALTER TABLE ONLY backup_labels - ADD CONSTRAINT fk_7de4989a69 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY merge_requests ADD CONSTRAINT fk_7e85395a64 FOREIGN KEY (sprint_id) REFERENCES sprints(id) ON DELETE CASCADE; @@ -25979,9 +25953,6 @@ ALTER TABLE ONLY serverless_domain_cluster ALTER TABLE ONLY labels ADD CONSTRAINT fk_rails_c1ac5161d8 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; -ALTER TABLE ONLY backup_labels - ADD CONSTRAINT fk_rails_c1ac5161d8 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; - ALTER TABLE ONLY project_feature_usages ADD CONSTRAINT fk_rails_c22a50024b FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; |