OperationalError:no such table

20 views
Skip to first unread message

hamza bouissi

unread,
May 7, 2017, 9:20:18 AM5/7/17
to Django users

after I add new model and delete all  other models and their migration files I ran makemigrations followed by migrate command, Unfortunately, I got OperationalError: no such table




Felipe Brunelli de Andrade

unread,
May 7, 2017, 10:16:16 AM5/7/17
to django...@googlegroups.com
Just check if the table exists in database!

2017-05-07 7:54 GMT-03:00 hamza bouissi <bouiss...@gmail.com>:

after I add new model and delete all  other models and their migration files I ran makemigrations followed by migrate command, Unfortunately, I got OperationalError: no such table




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/07639bc2-df9e-487e-9fdd-5cc2c98bc44d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Melvyn Sopacua

unread,
May 8, 2017, 8:35:30 AM5/8/17
to django...@googlegroups.com

On Sunday 07 May 2017 03:54:39 hamza bouissi wrote:

> after I add new model and delete all other models and their migration

> files

 

You still have a reference to one of the deleted models in your urls or a view that is referenced by that url.

 

Also, this isn't the way to do it.

First make a migration for the removed models, then add the new model and it's migration. Then run squashmigrations, start at the first migration and end with the last.

In theory you should be left with only 1 operation, the one that creates the new model.

If you then run migrate, the database will be migrated correctly using all individual migrations but new installs will only use the squashed migration.

 

--

Melvyn Sopacua

Reply all
Reply to author
Forward
0 new messages