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

Change unique_together to use constraints, replace use of index_together #196

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

norkans7
Copy link
Contributor

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Aug 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.33%. Comparing base (8f5bb86) to head (8bb30aa).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #196   +/-   ##
=======================================
  Coverage   93.33%   93.33%           
=======================================
  Files          29       29           
  Lines        1845     1845           
=======================================
  Hits         1722     1722           
  Misses        123      123           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@norkans7 norkans7 force-pushed the update-deps branch 2 times, most recently from b69715b to d4d3628 Compare August 21, 2024 13:00
@@ -50,7 +50,9 @@ def __str__(self):

class Meta:
ordering = ["name"]
unique_together = ("name", "org")
constraints = [
models.UniqueConstraint(fields=["name", "org"], name="categories_category_name_318a92307e6f39fb_uniq")
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this weird name is to avoid a migration ? There's not many categories so it's not a problem to remove and and re-add this index.. might be nicer just to call it categories_category_name_unique

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reused the existing index name

Copy link
Contributor

Choose a reason for hiding this comment

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

I get that but I'm not sure it's worth it or that that name is guaranteed to be the one used on every deployment

@@ -397,7 +397,9 @@ def get_time_taken(self):
return (until - self.started_on).total_seconds()

class Meta:
unique_together = ("org", "task_key")
constraints = [
models.UniqueConstraint(fields=["org", "task_key"], name="orgs_taskstate_org_id_70fc0194720c6cf5_uniq")
Copy link
Contributor

Choose a reason for hiding this comment

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

as above

),
migrations.AlterIndexTogether(
name="dashblocktype",
index_together={("slug", "name")},
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to rewrite existing migrations? I think we just let it generate new ones which I think will noop anyway.

),
migrations.AddIndex(
model_name="orgbackend",
index=models.Index(fields=["org", "is_active", "slug"], name="orgs_orgbac_org_id_607508_idx"),
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there's guarantee that generated index names are the same across deploys... just let Django make a new migrations

Copy link
Contributor

Choose a reason for hiding this comment

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

Or at least get Dash running on 5.0, which I think is smarter about changes to index_together than 4.2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I am going to remove the update to 5.1 and change the index_together changes first

@norkans7 norkans7 force-pushed the update-deps branch 2 times, most recently from bf9d3ac to ff1df2c Compare August 21, 2024 15:55
@norkans7 norkans7 changed the title Support Django 5.1 Change unique_together to use constraints, replace use of index_together Aug 21, 2024
@norkans7 norkans7 mentioned this pull request Aug 21, 2024
@norkans7 norkans7 merged commit 8913c67 into main Aug 22, 2024
14 checks passed
@norkans7 norkans7 deleted the update-deps branch August 22, 2024 14:52
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.

3 participants