-1

I built an internal app that used django-safedelete. I was working fine for months, until i recently upgraded my distro, and tried to add a field to my model. I also upgraded my python modules, everything is up-to-date, and no errors during the upgrade.

Now I cannot migrate anymore:

  • if I "makemigrations" I get an error message "django.db.utils.OperationalError: (1054, "Unknown column 'gestion_ltqmappsetting.deleted_by_cascade' in 'field list'")"

  • if I add a boolean "deleted_by_cascade" field in my ltqmappsetting table, then the "makemigration" works, but the "migrate" fails with "MySQLdb.OperationalError: (1060, "Duplicate column name 'deleted_by_cascade'")"

I tried removing the field after makemigrations, but the migrate fails with the first error message. I also tried removing the "migration" operations in the 0087...migration.py file, but it does not have any impact.

Is there anyway to update the migration file between the makemigrations and the migrate commands ?

Thanks a lot for any help on this. jm

Jm Lamotte
  • 11
  • 3

1 Answers1

0

It's a wonder how I can actually look for answers for hours, then post on this site, and a few minutes later, I actually find the answer ...

Anyway. It looked like I was mistaken on the meaning of the second error message. It failed because a previous migration already create the deleted_by_cascade field in another table, not in the appsetting one.

So the steps to solve my issue where:

  • migrate migrate 0086 to remove the latest migrations
  • make sure the DB only had the deleted_by_cascade column in the appsetting table
  • makemigrations - this creates the 0087 migration to add deleted_by_cascade column in all tables
  • edit the 0087 migration to not create the new column in the appsetting table
  • run makemigrations once again - - this creates the 0088 migration to add deleted_by_cascade column in the appsetting table
  • migrate 0087
  • migrate --fake 0088

Et voila ...

There was probably something wrong in the safe_delete update.

Hope this can help others.

jm

Jm Lamotte
  • 11
  • 3