Skip to content

Fix rollback on async foreign key constraints

Marius Bobin requested to merge 390651-refactor-async-fks-7 into master

What does this MR do and why?

Because we've added the constraint_type column after the table was created and there are a few migrations that use the helper already, when we rollback migrations past the one that added the column, the re-up part will fail because it's using the latest code version which adds the filter on constraint_type. In that case we must not apply the filter and let the migration that adds the column to populate it with the default value. We were using columns_hash to check for column existence, but this is cached by Rails internals, so it can return true if the column is not actually there.

Screenshots or screen recordings

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

How to set up and validate locally

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

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 #390651 (closed)

Edited by Marius Bobin

Merge request reports