From ace0df53d3ed38344b470727d430484d24eeb798 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 30 Nov 2020 18:09:46 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- ...1119125730_add_web_hooks_service_foreign_key.rb | 23 ++++++++++++++++++++++ db/schema_migrations/20201119125730 | 1 + db/structure.sql | 5 +++++ 3 files changed, 29 insertions(+) create mode 100644 db/migrate/20201119125730_add_web_hooks_service_foreign_key.rb create mode 100644 db/schema_migrations/20201119125730 (limited to 'db') diff --git a/db/migrate/20201119125730_add_web_hooks_service_foreign_key.rb b/db/migrate/20201119125730_add_web_hooks_service_foreign_key.rb new file mode 100644 index 00000000000..d350a7de282 --- /dev/null +++ b/db/migrate/20201119125730_add_web_hooks_service_foreign_key.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class AddWebHooksServiceForeignKey < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_web_hooks_on_service_id' + + disable_ddl_transaction! + + def up + add_concurrent_index :web_hooks, :service_id, name: INDEX_NAME + add_concurrent_foreign_key :web_hooks, :services, column: :service_id, on_delete: :cascade, validate: false + end + + def down + with_lock_retries do + remove_foreign_key_if_exists :web_hooks, column: :service_id + end + + remove_concurrent_index_by_name :web_hooks, INDEX_NAME + end +end diff --git a/db/schema_migrations/20201119125730 b/db/schema_migrations/20201119125730 new file mode 100644 index 00000000000..39de483e890 --- /dev/null +++ b/db/schema_migrations/20201119125730 @@ -0,0 +1 @@ +9fb3c338c999617b40e4c63f24ea037b5b1403354b93c2117e028ad8348d96aa \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index beb05a5c5e6..d99e6a8c2ca 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -22528,6 +22528,8 @@ CREATE INDEX index_web_hooks_on_group_id ON web_hooks USING btree (group_id) WHE CREATE INDEX index_web_hooks_on_project_id ON web_hooks USING btree (project_id); +CREATE INDEX index_web_hooks_on_service_id ON web_hooks USING btree (service_id); + CREATE INDEX index_web_hooks_on_type ON web_hooks USING btree (type); CREATE UNIQUE INDEX index_webauthn_registrations_on_credential_xid ON webauthn_registrations USING btree (credential_xid); @@ -23398,6 +23400,9 @@ ALTER TABLE ONLY environments ALTER TABLE ONLY ci_builds ADD CONSTRAINT fk_d3130c9a7f FOREIGN KEY (commit_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE; +ALTER TABLE ONLY web_hooks + ADD CONSTRAINT fk_d47999a98a FOREIGN KEY (service_id) REFERENCES services(id) ON DELETE CASCADE NOT VALID; + ALTER TABLE ONLY ci_sources_pipelines ADD CONSTRAINT fk_d4e29af7d7 FOREIGN KEY (source_pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE; -- cgit v1.2.3