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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion django_celery_results/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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...

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('django_celery_results', '0011_taskresult_periodic_task_name'),
]

operations = [
migrations.AlterField(
model_name='chordcounter',
name='id',
field=models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name='ID',
),
),
migrations.AlterField(
model_name='groupresult',
name='id',
field=models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name='ID',
),
),
migrations.AlterField(
model_name='taskresult',
name='id',
field=models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name='ID',
),
),
]
Loading