Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to switch to a new database

I want to deploy my django project to the production environments, and associated it with an new empty database, and I did as follows :

  1. Create an new empty database
  2. Updated settings.py and pointed the database name to the new one
  3. Deleted the migrations folder under my App
  4. Run python manage.py runserver and no errors returned
  5. Run python manage.py makemigrations and python manage.py migrate

but only auth related tables created ( like auth_user , auth_group ... ), no databases tables created for my Apps

How should I do for this situation to move to the new database for my project?

like image 855
JiangLing Avatar asked Nov 29 '22 09:11

JiangLing


1 Answers

  1. Deleted the migrations folder under my App

This was your mistake, you deleted the migrations - including the initial migrations. So when you go to makemigrations you haven't got the initial migration available.

So you need to run makemigrations <app_name> to at least get the initial migration.

If you were to do this again, don't delete the migrations, just change the database settings and then migrate.

like image 96
Sayse Avatar answered Dec 06 '22 08:12

Sayse