Skip to content

Improve Docs for replacing a foreign key with different ON DELETE

Dylan Griffith requested to merge docs-foreign-key-replace-with-on-nullify into master

What does this MR do and why?

Improve Docs for replacing a foreign key with different ON DELETE

The previous documentation recommended to add the new foreign key in multiple migrations with validate: false. There doesn't seem to be any reason for this. The original discussion tracks back to !82414 (comment 867380679) but this line of reasoning isn't really applicable because the performance issues being described are mitigated by the fact that add_concurrent_foreign_key already separates validation from creation.

This change also fixes the issue with the original documentation where our def down method was leaving the database schema in a different state because we weren't validating the foreign key when re-adding it. This caused confusion at !163253 (comment 2071425164) because this causes the pipeline to fail.

There was also a discussion on Slack (internal) and we couldn't think of any reason to separate validation when doing this process.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Merge request reports

Loading