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

Not all migrations seems to be included #388

Open
frlan opened this issue Oct 6, 2024 · 3 comments
Open

Not all migrations seems to be included #388

frlan opened this issue Oct 6, 2024 · 3 comments
Labels

Comments

@frlan
Copy link
Contributor

frlan commented Oct 6, 2024

When running makemigrations Django is finding some new ones

django-user-accounts==3.3.2

manage.py makemigrations
Migrations for 'account':
 
venv/lib/python3.12/site-packages/account/migrations/0008_auto_20241005_1431.py
    - Alter field id on account
    - Alter field id on accountdeletion
    - Alter field id on emailaddress
    - Alter field id on emailconfirmation
    - Alter field id on passwordexpiry
    - Alter field id on passwordhistory
    - Alter field id on signupcode
    - Alter field id on signupcoderesult 

The migration here created looks like

# Generated by Django 5.1.1 on 2024-10-05 13:32

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("account", "0007_alter_emailconfirmation_sent"),
    ]

    operations = [
        migrations.AlterField(
            model_name="account",
            name="id",
            field=models.BigAutoField(
                auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
            ),
        ),
        migrations.AlterField(
            model_name="accountdeletion",
            name="id",
            field=models.BigAutoField(
                auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
            ),
        ),
        migrations.AlterField(
            model_name="emailaddress",
            name="id",
            field=models.BigAutoField(
                auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
            ),
        ),
        migrations.AlterField(
            model_name="emailconfirmation",
            name="id",
            field=models.BigAutoField(
                auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
            ),
        ),
        migrations.AlterField(
            model_name="passwordexpiry",
            name="id",
            field=models.BigAutoField(
                auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
            ),
        ),
        migrations.AlterField(
            model_name="passwordhistory",
            name="id",
            field=models.BigAutoField(
                auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
            ),
        ),
        migrations.AlterField(
            model_name="signupcode",
            name="id",
            field=models.BigAutoField(
                auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
            ),
        ),
        migrations.AlterField(
            model_name="signupcoderesult",
            name="id",
            field=models.BigAutoField(
                auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
            ),
        ),
    ]
@frlan frlan added the Bug label Oct 6, 2024
@uhurusurfa
Copy link
Collaborator

Thats because you re running Django 5 - this app has not been updated to support that version yet.

@phill-zarfos-accrisoft
Copy link

I don't think that Django 5 is the issue. I got similar migrations running Django 4.2 :

  • Django 4.2
  • django-user-accounts==3.3.2
  • PostgreSQL 14.12
% python manage.py makemigrations account
Migrations for 'account':
  /usr/local/lib/python3.10/dist-packages/account/migrations/0008_alter_account_id_alter_accountdeletion_id_and_more.py
    - Alter field id on account
    - Alter field id on accountdeletion
    - Alter field email on emailaddress
    - Alter field id on emailaddress
    - Alter field id on emailconfirmation
    - Alter field id on passwordexpiry
    - Alter field id on passwordhistory
    - Alter field id on signupcode
    - Alter field id on signupcoderesult
    - Alter unique_together for emailaddress (1 constraint(s))

The resulting 0008_alter_account_id_alter_accountdeletion_id_and_more.py migration file was similar to frian's file, but only slightly different:

# Generated by Django 4.2.15 on 2024-11-05 19:26

from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('account', '0007_alter_emailconfirmation_sent'),
    ]

    operations = [
        migrations.AlterField(
            model_name='account',
            name='id',
            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
        ),
        migrations.AlterField(
            model_name='accountdeletion',
            name='id',
            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
        ),
        migrations.AlterField(
            model_name='emailaddress',
            name='email',
            field=models.EmailField(max_length=254),
        ),
        migrations.AlterField(
            model_name='emailaddress',
            name='id',
            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
        ),
        migrations.AlterField(
            model_name='emailconfirmation',
            name='id',
            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
        ),
        migrations.AlterField(
            model_name='passwordexpiry',
            name='id',
            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
        ),
        migrations.AlterField(
            model_name='passwordhistory',
            name='id',
            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
        ),
        migrations.AlterField(
            model_name='signupcode',
            name='id',
            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
        ),
        migrations.AlterField(
            model_name='signupcoderesult',
            name='id',
            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
        ),
        migrations.AlterUniqueTogether(
            name='emailaddress',
            unique_together={('user', 'email')},
        ),
    ]

Are there any migrations missing from this project's source code?

@uhurusurfa
Copy link
Collaborator

The models in this app rely on Django auto assigning a primary key. the original models were generated when the default was "AutoField".
https://docs.djangoproject.com/en/2.2/topics/db/models/#automatic-primary-key-fields

Your migrations are using "BigAutoField" and hence the perceived change.
Django 4 and 5 are the same using BigAutofield:
https://docs.djangoproject.com/en/5.1/topics/db/models/#automatic-primary-key-fields

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants