Missing foreign key constraint on web_hooks.group_id
It looks like there is only one for project_id
:
Foreign-key constraints:
"fk_0c8ca6d9d1" FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE
Referenced by:
TABLE "web_hook_logs" CONSTRAINT "fk_rails_666826e111" FOREIGN KEY (web_hook_id) REFERENCES web_hooks(id) ON DELETE CASCADE
We may also want to consider getting rid of this STI table and migrating group hooks into another table (or use an enum type instead of the string type
).
Iterations
Adding foreign key constraint to an existing column.
-
Add a NOT VALID
foreign key constraint to the column to ensure GitLab doesn’t create inconsistent records. %13.11 !57735 (merged) -
Add a data migration, to fix or clean up existing records. %13.11 !57863 (merged) -
Fix invalid data WHERE "web_hooks"."group_id" IS NOT NULL AND "web_hooks"."project_id" IS NOT NULL
%13.12 !60527 (merged) -
Validate the whole table by making the foreign key VALID
. %13.12 !60527 (merged) -
Remove dependent: :destroy
. %13.12 !60527 (merged)
Edited by Arturo Herrero