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

Upate all uniqueness validation to employ UniqueConstraint classes #10361

Closed
jeremystretch opened this issue Sep 14, 2022 · 0 comments
Closed
Assignees
Labels
status: accepted This issue has been accepted for implementation type: housekeeping Changes to the application which do not directly impact the end user
Milestone

Comments

@jeremystretch
Copy link
Member

Proposed Changes

Replace all instances of unique_together under a model Meta class with a list of UniqueConstraint instances defined under constraints. Additionally, and custom overrides of a model's validate_unique() method should be removed where possible.

Justification

UniqueConstraint was introduced in Django 4.0 and allows for conditional evaluation. This should allow us to ditch any custom validate_unique() logic, such as what is currently defined for the Device model. The Django docs also recommend moving away from unique_together in general as it will likely be deprecated in the future.

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation type: housekeeping Changes to the application which do not directly impact the end user labels Sep 14, 2022
@jeremystretch jeremystretch added this to the v3.4 milestone Sep 14, 2022
@jeremystretch jeremystretch self-assigned this Sep 14, 2022
jeremystretch added a commit that referenced this issue Sep 27, 2022
Closes #10361: Migrate from unique_together to UniqueConstraints
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: housekeeping Changes to the application which do not directly impact the end user
Projects
None yet
Development

No branches or pull requests

1 participant