1

i develope a django project on my local system, and now i deployed that to a server. i used MySql as database. whenever i try to migrate my models (using python manage.py migrate or python manage.py makemigrations) to server's new database, it shows me following error:

django.db.utils.ProgrammingError: (1146, "Table '<DB_NAME>.mainapp_service' doesn't exist")

and doesn't create tables into the database.

i didn't move any of my local migration files to server, just moved mainapp/migrations/__init__.py file.

how can i create all tables and run my app?

Omid Adib
  • 170
  • 1
  • 8

1 Answers1

2

You really shouldn't run makemigrations on the server. You should include migrations in version control and push your migrations files to the server and then run migrate. Make sure you have created the database on the server and that you have it confugured in settings.py. Check out the Workflow section on migrations.

Rob Vezina
  • 628
  • 3
  • 9
  • Oh i really didnt know that i should include migration files to vcs, i completely ignored them and i dont have them now! What can i do? Is there anyway to re-create migrations out of models? – Omid Adib Apr 08 '20 at 14:57
  • Yeah. You want to make sure they're working properly before you put them on the server. – Rob Vezina Apr 08 '20 at 15:02