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 default_auto_field to BigAutoField #426

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

browniebroke
Copy link
Contributor

@browniebroke browniebroke commented Mar 20, 2024

Fix #307

Or at least make the issue much less frequent...

@browniebroke
Copy link
Contributor Author

I don't understand the test failure, they seem unrelated with my changes... Are they broken due to an external factor or am I missing something obvious?

@charlesobrien
Copy link
Contributor

@browniebroke They're failing because Pytest was unconstrained and breaking changes in Pytest 8 (released in Jan) are blowing up the tests.

My PR #425 to add Django 5 to CI also places a constraint on pytest. Hoping it might be able to get reviewed/merged soon.

@browniebroke
Copy link
Contributor Author

Thanks a lot! Will wait for a bit then.

@@ -12,4 +12,4 @@ class CeleryResultConfig(AppConfig):
name = 'django_celery_results'
label = 'django_celery_results'
verbose_name = _('Celery Results')
default_auto_field = 'django.db.models.AutoField'
default_auto_field = 'django.db.models.BigAutoField'
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious, if this change is backward compatible?

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 think it's backwards compatible. It's changing the DB type from an integer field to a 64-bit integer, increasing its range.

However, I have a few concerns for users of the library:

  • I'm not sure if there are any performances considerations when applying this migration on a table with a large number of rows. Would the migrate script takes a while to run? What kind of locks does it need? How does it varies between databases?
  • The django docs have a large note about the change, and if folks have a many to many field that link to one of the tables, they'll need to do an extra migration:

    Unfortunately, the primary keys of existing auto-created through tables cannot currently be updated by the migrations framework.

So it might be worthy of a major bump to signal these pitfalls...

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.

Reaching maximum value for TaskResult primary key field causes task failures
3 participants