Skip to content

Fix DROP index vs constraint issue (#38) #39

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 2 commits into from
Mar 10, 2020

Conversation

sparrowt
Copy link

The return value from _constraint_names includes unique indexes even if these are not actual constraints.

Therefore trying to drop these using sql_delete_unique ("ALTER TABLE ... DROP CONSTRAINT ...") will fail because it is an index, not a constraint.

Instead explicitly deal with unique indexes separately.

With this patch I can no longer repro the issue at #38

`_constraint_names` return value includes unique
indexes even if these are not actual constraints.

Trying to drop these using `sql_delete_unique`
(ALTER TABLE ... DROP CONSTRAINT ...) will fail
because it is an index, not a constraint.

Instead explicitly deal with unique indexes separately.
@OskarPersson
Copy link
Collaborator

Looks good! Could you add a test model along with 2 migrations and some test that tests this?

@sparrowt
Copy link
Author

sparrowt commented Mar 9, 2020

Added 👍 The successful running of the 2 new test migrations should be sufficient to test this - not sure what we would be testing in an explicit test case method?

@OskarPersson
Copy link
Collaborator

Looks good, thank you! 👍

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.

Migration failure making unique column non-nullable: Could not drop constraint
2 participants