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

Conflicting migrations detected after 2.0.0->2.1.0 #247

Open
elnygren opened this issue Mar 19, 2024 · 3 comments
Open

Conflicting migrations detected after 2.0.0->2.1.0 #247

elnygren opened this issue Mar 19, 2024 · 3 comments

Comments

@elnygren
Copy link

elnygren commented Mar 19, 2024

After upgrading 2.0.0 -> 2.1.0

CommandError: Conflicting migrations detected
multiple leaf nodes in the migration graph: (0004_alter_invitation_id, 0004_auto_20230328_1430 in invitations).
./manage.py showmigrations

invitations
 [X] 0001_initial
 [X] 0002_auto_20151126_0426
 [X] 0003_auto_20151126_1523
 [X] 0004_alter_invitation_id
 [ ] 0004_auto_20230328_1430

Contents of 0004_alter_invitation_id

# Generated by Django 4.2.5 on 2023-11-06 23:00

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"),
        ),
    ]

Contents of 0004_auto_20230328_1430

# Generated by Django 3.2.15 on 2023-03-28 14:30

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


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('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'),
        ),
        migrations.AlterField(
            model_name='invitation',
            name='inviter',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='inviter'),
        ),
    ]
@elnygren
Copy link
Author

elnygren commented Mar 19, 2024

So it seems the upgrade path for django-invitations is something like:

  1. manually rollback 0004 (manage.py migrate invitations 0003) and hope it doesn't destroy any data
  2. update to 2.1.0 (pip-sync or whatever)
  3. manage.py migrate

?

Edit:

Hmm weird, I did not have the other 0004_alter_invitation_id in prod at all but did have it in dev 🤔

@stefanfeuerhahn
Copy link

pip does not seem to remove the migrations when uninstalling or upgrading the django-invitations package. I therefore solved the above problem by manually deleting the migration, e.g. remove .venv/lib/python3.12/site-packages/invitations/

@Flimm
Copy link
Contributor

Flimm commented Jun 14, 2024

I noticed that there was a missing migration file in this library, so I created it in this commit: 8ae641f In that commit, I also added a test to make sure that we don't forget to create migration files in the future.

Does this solve the issue for you?

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