Skip to content
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

Fixed #23740 -- Fixed removing unique_together constraint if exists primary key/unique constraint on the same field. #15732

Merged
merged 2 commits into from May 26, 2022

Conversation

David-Wobrock
Copy link
Member

Hi,

Tackling ticket-23740.

In short:

1/ If the field is the primary key, fix it by filtering on "primary_key": False in django.db.backends.base.schema.BaseDatabaseSchemaEditor.alter_unique_together

2/ If the field has a unique=True constraint, to fix we check that the constraint name is the default one we would give to a unique_together constraint, based on the observation that a unique=True and a unique_together constraints are named differently at the time of writing

@David-Wobrock David-Wobrock marked this pull request as ready for review May 24, 2022 14:06
Copy link
Member

@felixxm felixxm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@David-Wobrock Thanks 👍 I left comments.

django/db/backends/base/schema.py Outdated Show resolved Hide resolved
django/db/backends/base/schema.py Outdated Show resolved Hide resolved
tests/migrations/test_operations.py Show resolved Hide resolved
django/db/backends/base/schema.py Outdated Show resolved Hide resolved
@David-Wobrock
Copy link
Member Author

Thanks for the review @felixxm 🙏
I amended and pushed the commit with the changes.

@felixxm felixxm self-assigned this May 26, 2022
@felixxm felixxm changed the title Fixed #23740 -- Allowed dropping unique_together on a single field with unique=True Fixed #23740 -- Fixed removing unique_together constraint if exists primary key/unique constraint on the same field. May 26, 2022
@felixxm
Copy link
Member

felixxm commented May 26, 2022

@David-Wobrock Thanks 👍

…rimary key/unique constraint on the same field.
@felixxm felixxm merged commit b949e40 into django:main May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants