Commit ea3fb7ea authored by Andy Soiron's avatar Andy Soiron Committed by Tiger Watson

Cascade delete inheriting services

parent 3549441a
---
title: Change services.inherit_from_id foreign key to ON DELETE CASCADE
merge_request: 48163
author:
type: fixed
# frozen_string_literal: true
class ChangeServicesInheritFromIdForeignKey < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_foreign_key :services, :services, column: :inherit_from_id, on_delete: :cascade, name: 'fk_services_inherit_from_id'
remove_foreign_key_if_exists :services, name: 'fk_868a8e7ad6'
end
def down
remove_foreign_key_if_exists :services, name: 'fk_services_inherit_from_id'
add_concurrent_foreign_key :services, :services, column: :inherit_from_id, on_delete: :nullify, name: 'fk_868a8e7ad6'
end
end
c41f4649540c23d25f0ae26c3754476409b5e77f53b96db65f2c1fd4a6caf087
\ No newline at end of file
......@@ -23124,9 +23124,6 @@ ALTER TABLE ONLY merge_request_diffs
ALTER TABLE ONLY ci_pipelines
ADD CONSTRAINT fk_86635dbd80 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY services
ADD CONSTRAINT fk_868a8e7ad6 FOREIGN KEY (inherit_from_id) REFERENCES services(id) ON DELETE SET NULL;
ALTER TABLE ONLY geo_event_log
ADD CONSTRAINT fk_86c84214ec FOREIGN KEY (repository_renamed_event_id) REFERENCES geo_repository_renamed_events(id) ON DELETE CASCADE;
......@@ -24792,6 +24789,9 @@ ALTER TABLE ONLY resource_label_events
ALTER TABLE ONLY ci_builds_metadata
ADD CONSTRAINT fk_rails_ffcf702a02 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY services
ADD CONSTRAINT fk_services_inherit_from_id FOREIGN KEY (inherit_from_id) REFERENCES services(id) ON DELETE CASCADE;
ALTER TABLE ONLY timelogs
ADD CONSTRAINT fk_timelogs_issues_issue_id FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment