Commit b8dffa3b authored by Adam Hegyi's avatar Adam Hegyi

Merge branch 'update-terraform-states-user-foreign-key' into 'master'

Change terraform_states.locked_by_user_id foreign key to SET NULL

See merge request gitlab-org/gitlab!55813
parents 40c19a06 918e2c79
---
title: Change terraform_states.locked_by_user_id foreign key to SET NULL
merge_request: 55813
author:
type: fixed
# frozen_string_literal: true
class UpdateTerraformStatesLockedByUserIdForeignKey < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
OLD_FOREIGN_KEY = 'fk_rails_558901b030'
NEW_FOREIGN_KEY = 'fk_558901b030'
disable_ddl_transaction!
def up
add_concurrent_foreign_key :terraform_states, :users,
column: :locked_by_user_id, on_delete: :nullify, name: NEW_FOREIGN_KEY
with_lock_retries do
remove_foreign_key :terraform_states, :users, name: OLD_FOREIGN_KEY
end
end
def down
add_concurrent_foreign_key :terraform_states, :users,
column: :locked_by_user_id, on_delete: nil, name: OLD_FOREIGN_KEY
with_lock_retries do
remove_foreign_key :terraform_states, :users, name: NEW_FOREIGN_KEY
end
end
end
c91541048b119bcbbe9454760c6a90ddb6c4dc90e121f3ee7f4cdd6a1bde2c9e
\ No newline at end of file
...@@ -24455,6 +24455,9 @@ ALTER TABLE ONLY path_locks ...@@ -24455,6 +24455,9 @@ ALTER TABLE ONLY path_locks
ALTER TABLE ONLY clusters_applications_prometheus ALTER TABLE ONLY clusters_applications_prometheus
ADD CONSTRAINT fk_557e773639 FOREIGN KEY (cluster_id) REFERENCES clusters(id) ON DELETE CASCADE; ADD CONSTRAINT fk_557e773639 FOREIGN KEY (cluster_id) REFERENCES clusters(id) ON DELETE CASCADE;
ALTER TABLE ONLY terraform_states
ADD CONSTRAINT fk_558901b030 FOREIGN KEY (locked_by_user_id) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE ONLY merge_request_metrics ALTER TABLE ONLY merge_request_metrics
ADD CONSTRAINT fk_56067dcb44 FOREIGN KEY (target_project_id) REFERENCES projects(id) ON DELETE CASCADE; ADD CONSTRAINT fk_56067dcb44 FOREIGN KEY (target_project_id) REFERENCES projects(id) ON DELETE CASCADE;
...@@ -25481,9 +25484,6 @@ ALTER TABLE ONLY geo_node_namespace_links ...@@ -25481,9 +25484,6 @@ ALTER TABLE ONLY geo_node_namespace_links
ALTER TABLE ONLY clusters_applications_knative ALTER TABLE ONLY clusters_applications_knative
ADD CONSTRAINT fk_rails_54fc91e0a0 FOREIGN KEY (cluster_id) REFERENCES clusters(id) ON DELETE CASCADE; ADD CONSTRAINT fk_rails_54fc91e0a0 FOREIGN KEY (cluster_id) REFERENCES clusters(id) ON DELETE CASCADE;
ALTER TABLE ONLY terraform_states
ADD CONSTRAINT fk_rails_558901b030 FOREIGN KEY (locked_by_user_id) REFERENCES users(id);
ALTER TABLE ONLY issuable_metric_images ALTER TABLE ONLY issuable_metric_images
ADD CONSTRAINT fk_rails_56417a5a7f FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE; ADD CONSTRAINT fk_rails_56417a5a7f 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