Commit aff84c08 authored by Dylan Griffith's avatar Dylan Griffith Committed by Adam Hegyi

Remove foreign key ci_minutes_additional_packs.namespace_id

In https://gitlab.com/gitlab-org/gitlab/-/merge_requests/77322 we
already added a ["loose foreign key"](
https://docs.gitlab.com/ee/development/database/loose_foreign_keys.html)
to replace this foreign key. Now that this has been running fine in
production we should be OK to remove the foreign key altogether.

This was added in a post-deployment migration as we want to ensure that
they have the correct code running with the loose foreign key in place
before we remove the foreign key to ensure that there isn't any lost
deletes.

Changelog: other
parent 55bbd7d1
# frozen_string_literal: true
class RemoveCiMinutesAdditionalPacksNamespaceIdForeignKeyConstraint < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
CONSTRAINT_NAME = 'fk_rails_e0e0c4e4b1'
def up
with_lock_retries do
remove_foreign_key_if_exists(:ci_minutes_additional_packs, :namespaces, name: CONSTRAINT_NAME)
end
end
def down
add_concurrent_foreign_key :ci_minutes_additional_packs, :namespaces, column: :namespace_id, on_delete: :cascade, name: CONSTRAINT_NAME
end
end
301c2f09f48aa3e34c2f679628a9542b4babc589e3d20e9ccf84a9209f5841ee
\ No newline at end of file
......@@ -31270,9 +31270,6 @@ ALTER TABLE ONLY analytics_cycle_analytics_group_stages
ALTER TABLE ONLY bulk_import_export_uploads
ADD CONSTRAINT fk_rails_dfbfb45eca FOREIGN KEY (export_id) REFERENCES bulk_import_exports(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_minutes_additional_packs
ADD CONSTRAINT fk_rails_e0e0c4e4b1 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
ALTER TABLE ONLY label_priorities
ADD CONSTRAINT fk_rails_e161058b0f FOREIGN KEY (label_id) REFERENCES labels(id) ON DELETE CASCADE;
......@@ -34,4 +34,10 @@ RSpec.describe Ci::Minutes::AdditionalPack, type: :model do
it { is_expected.not_to validate_uniqueness_of(:purchase_xid) }
end
end
it_behaves_like 'cleanup by a loose foreign key' do
let!(:model) { create(:ci_minutes_additional_pack) }
let!(:parent) { model.namespace }
end
end
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