Skip to content

Conversation

andrew-farries
Copy link
Collaborator

@andrew-farries andrew-farries commented Jan 23, 2025

Ensure that multi-operation migrations combining alter_column operations setting foreign key constraints work in combination with other operations.

Add testcases for:

  • rename referencing table, set foreign key
  • rename referencing table, rename referencing column, set foreign key
  • rename referenced table, set foreign key,
  • rename referenced column, set foreign key

Previously these migrations would fail as the alter_column operation was unaware of the changes made by the preceding operation.

Part of #239

When adding a FK constraint to a column, take the table and column name
from the virtual schema instead of the operation. This ensures that the
operation is aware of any table and column renames that were done by
previous operations in the same migration.
Take the name of the referenced table from the virtual schema instead of
the operation. This ensures that the correct table name is used when the
referenced table has been renamed by a preceding operation in the same
migration.
Take the name of the referenced column from the virtual schema instead
of the operation. This ensures that the correct column name is used when
the referenced column has been renamed by a preceding operation in the
same migration.
@andrew-farries andrew-farries force-pushed the multi-op-support-for-set-fk branch from fd06108 to 1e8375a Compare January 23, 2025 09:18
@andrew-farries andrew-farries marked this pull request as ready for review January 23, 2025 09:23
@andrew-farries andrew-farries merged commit db21651 into main Jan 23, 2025
28 checks passed
@andrew-farries andrew-farries deleted the multi-op-support-for-set-fk branch January 23, 2025 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants