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

Extraneous migrations are generated when settings.DEFAULT_AUTO_FIELD is set to BigAutoField #224

Open
knyghty opened this issue Jul 8, 2023 · 5 comments

Comments

@knyghty
Copy link
Member

knyghty commented Jul 8, 2023

Related to these changes: https://docs.djangoproject.com/en/4.2/releases/3.2/#customizing-type-of-auto-created-primary-keys

This makes it difficult for example to have a CI step to check for missing migrations, as this package is always generating a migration file.

This can be fixed by setting default_auto_field for the models in the project, and making a migration for them if necessary.

@mdrie
Copy link
Contributor

mdrie commented Aug 21, 2023

Is there a work-around for this? Is it possible to put the missing migration into my project?

@knyghty
Copy link
Member Author

knyghty commented Aug 21, 2023

Is there a work-around for this? Is it possible to put the missing migration into my project?

Not really, no. it needs to be fixed in this repo.

@valberg
Copy link
Contributor

valberg commented Aug 21, 2023

Hi @knyghty

Can you provide me with more info? Especially what the content of the migration file being generated is.

We already have the apps.Config.default_auto_field set to BigAutoField, and I'm not sure what you mean by "setting default_auto_field for the models in the project".

@knyghty
Copy link
Member Author

knyghty commented Aug 21, 2023

Hi @valberg,

The problem, as I understand it (which is somewhat, but not fully), is that there is currently the initial migration that uses AutoField: https://github.com/jazzband/django-invitations/blob/master/invitations/migrations/0001_initial.py#L17

Because this is generated from the implicit id field, i.e. it isn't specified explicitly in the Invitation model, Django now wants to generate this migration, which should be added to the project:

from django.db import migrations, models


class Migration(migrations.Migration):
    dependencies = [
        ("invitations", "0003_auto_20151126_1523"),
    ]

    operations = [
        migrations.AlterField(
            model_name="invitation",
            name="id",
            field=models.BigAutoField(
                auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
            ),
        ),
    ]

@knyghty
Copy link
Member Author

knyghty commented Aug 21, 2023

Ah, I now see that this has already been done, just not released, so sorry for the noise here. A release would be appreciated, though, if someone has the time to prep it.

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

No branches or pull requests

3 participants