Add foreign key from web_hooks to groups
What does this MR do?
Add a NOT VALID
foreign key constraint from web_hooks
to groups
to ensure it doesn't create inconsistent records.
Reference https://docs.gitlab.com/ee/development/database/add_foreign_key_to_existing_column.html.
Migration
rails db:migrate
$ rails db:migrate
== 20210325092215 AddNotValidForeignKeyToGroupHooks: migrating ================
-- add_foreign_key(:web_hooks, :namespaces, {:column=>:group_id, :on_delete=>:cascade, :validate=>false})
-> 0.0131s
== 20210325092215 AddNotValidForeignKeyToGroupHooks: migrated (0.0132s) =======
rails db:migrate:down VERSION=20210325092215
$ rails db:migrate:down VERSION=20210325092215
== 20210325092215 AddNotValidForeignKeyToGroupHooks: reverting ================
-- foreign_keys(:web_hooks)
-> 0.0068s
-- remove_foreign_key(:web_hooks, {:column=>:group_id})
-> 0.0051s
== 20210325092215 AddNotValidForeignKeyToGroupHooks: reverted (0.0120s) =======
Related to #202423 (closed)