0

I'm using Django 1.9 and somewhere in the development process the migrations tool stopped working and was throwing strange errors, therefore I wanted to start off with a new database (MySQL). So I removed all old migrations, created a new initial one with manage.py makemigrations, switched to a new empty DB in the settings and wanted to run manage.py migrate. The problem is that some of might existing code calls to tables that are not yet present in the new DB and this actually throws an error when I execute migrate.

django.db.utils.ProgrammingError: (1146, "Table 'new_db.old_table' doesn't exist")

How can I circumvent this problem?

Jarno
  • 6,243
  • 3
  • 42
  • 57
  • Try use `python manage migrate --fake` and then `migrate` again – Ivan Semochkin Apr 29 '16 at 08:50
  • So `--fake` throws exactly the same error, but I have managed the issue now with temporarily commenting the code out, though this is for sure no satisfactory solution for larger projects. – Jarno Apr 29 '16 at 09:06
  • @Jano you commented depencies to `old_table` in other migration file? Maybe problem is that `old_table` have no initial migration and `manage.py migrate --fake-initial` could help. Or maybe you just need create single `makemigration` to this table, like `manage.py makemigrations old_table` and then `migrate` it – Ivan Semochkin Apr 29 '16 at 09:27
  • @Baterson In fact, I removed all old migrations from the migrations folder and generate a new initial migration. The problem is SomeModel.objects.all() statement, that can't find its table in this state. – Jarno Apr 29 '16 at 09:31

0 Answers0