Skip to content

Add support for alter_table set unique operations in multi-operation migrations #609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 20, 2025

Conversation

andrew-farries
Copy link
Collaborator

Ensure that multi-operation migrations combining alter_column operations setting columns to UNIQUE works in combination with other operations.

Add testcases for:

  • rename table, set column unique
  • rename table, rename column, set column unique
  • create table, set column unique

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

Part of #239

@andrew-farries andrew-farries force-pushed the support-create-table-set-not-null branch from 03f78a6 to 632f47c Compare January 20, 2025 11:04
@andrew-farries andrew-farries force-pushed the support-set-unique-in-multi-op-migrations branch from ddddd4a to ac327e7 Compare January 20, 2025 11:04
@andrew-farries andrew-farries force-pushed the support-create-table-set-not-null branch from 632f47c to ce2b4dd Compare January 20, 2025 11:12
@andrew-farries andrew-farries force-pushed the support-set-unique-in-multi-op-migrations branch from ac327e7 to 57a9386 Compare January 20, 2025 11:12
Base automatically changed from support-create-table-set-not-null to main January 20, 2025 11:15
Ensure that a column on a table that has been renamed by a previous
operation can be made unique.
When setting a unique constraint on a column, take the table and column
name from the in-memory schema rather than the operation. This ensures
that the operation is aware of any renames applied to the table or
column by a preceding operation.
Ensure that the following sequence of operations in a migration
works correctly:

* Rename table
* Rename column
* Set unique constraint on the renamed column in the renamed table
@andrew-farries andrew-farries force-pushed the support-set-unique-in-multi-op-migrations branch from 57a9386 to 6a2c48b Compare January 20, 2025 11:16
@andrew-farries andrew-farries merged commit a9b35b5 into main Jan 20, 2025
28 checks passed
@andrew-farries andrew-farries deleted the support-set-unique-in-multi-op-migrations branch January 20, 2025 11:19
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