Skip to content

Remove chat_names -> ci_pipeline_chat_data FK

Adam Hegyi requested to merge 344818-remove-chat-names-fk into master

What does this MR do and why?

This MR removes the chat_names -> ci_pipeline_chat_data foreign key as part of the ongoing database decomposition work.

More context:

The referential integrity will be "eventually" ensured with the loose foreign key feature: https://docs.gitlab.com/ee/development/database/loose_foreign_keys

Note:

The foreign key is already dropped on staging and production so for GL.com it's a no-op.

Migration:

Up:

== 20211112113300 RemoveCiPipelineChatDataFkOnChatNames: migrating ============
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:ci_pipeline_chat_data)
   -> 0.0033s
-- remove_foreign_key(:ci_pipeline_chat_data, :chat_names, {:name=>"fk_rails_f300456b63"})
   -> 0.0069s
== 20211112113300 RemoveCiPipelineChatDataFkOnChatNames: migrated (0.0614s) ===

Down:

== 20211112113300 RemoveCiPipelineChatDataFkOnChatNames: reverting ============
-- execute("DELETE FROM ci_pipeline_chat_data\nWHERE\nNOT EXISTS (SELECT 1 FROM chat_names WHERE chat_names.id=ci_pipeline_chat_data.chat_name_id)\n")
   -> 0.0022s
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:ci_pipeline_chat_data)
   -> 0.0032s
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE ci_pipeline_chat_data\nADD CONSTRAINT fk_rails_f300456b63\nFOREIGN KEY (chat_name_id)\nREFERENCES chat_names (id)\nON DELETE CASCADE\nNOT VALID;\n")
   -> 0.0047s
-- execute("SET statement_timeout TO 0")
   -> 0.0009s
-- execute("ALTER TABLE ci_pipeline_chat_data VALIDATE CONSTRAINT fk_rails_f300456b63;")
   -> 0.0024s
-- execute("RESET statement_timeout")
   -> 0.0006s
== 20211112113300 RemoveCiPipelineChatDataFkOnChatNames: reverted (0.0284s) ===

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #344818 (closed)

Edited by Adam Hegyi

Merge request reports

Loading