0

I have three models: assembly, configurator, and genus. I want to move a "genus" foreign key from the assembly model to the configurator model. I moved it in the python code, generated a migration, and but that fails utterly:

django.db.utils.OperationalError: (1025, "Error on rename of './isotek_intranet_django/aion_assembly' to './isotek_intranet_django/#sql2-848-19e5' (errno: 152)")

Which is like useful but not. My backend database is MariaDB. Here is the relevant bits of the migration:

operations = [
    migrations.RemoveField(
        model_name='assembly',
        name='genus',
    ),
    migrations.AddField(
        model_name='configurator',
        name='genus',
        field=models.ForeignKey(default=1, to='aion.Genus'),
    ),
]

What (and why) am I doing wrong?

Note that I can run my tests just fine. It is updating a currently existing database that fails.

Django is 1.8 release.

1 Answers1

1

You're possibly running into this bug. In this case it means that you'll have to delete the constraint before dropping the foreign key. As a short term fix you can try to do this manually by following this answer.

Community
  • 1
  • 1
gbs
  • 1,255
  • 13
  • 12