Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pycharm: makemigrations and migrate ignore my changes

Here's what I'm doing all the time, and I guess it's not the right solution:

  • modify my models
  • delete the db.sqlite3 file
  • launch makemigrations then migrate

If I dont delete the db.sqlite3 file I have this when I try to run makemigrations then migrate:

manage.py@pyweb > makemigrations
"C:\Program Files (x86)\JetBrains\PyCharm 4.5.3\bin\runnerw.exe" C:\Python34\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 4.5.3\helpers\pycharm\django_manage.py" makemigrations C:/Users/Olivier/PycharmProjects/pyweb
No changes detected

Process finished with exit code 0
manage.py@pyweb > migrate
"C:\Program Files (x86)\JetBrains\PyCharm 4.5.3\bin\runnerw.exe" C:\Python34\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 4.5.3\helpers\pycharm\django_manage.py" migrate C:/Users/Olivier/PycharmProjects/pyweb
Operations to perform:
  Synchronize unmigrated apps: staticfiles, messages, produits
  Apply all migrations: sessions, auth, contenttypes, admin
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  No migrations to apply.

Process finished with exit code 0

What step am I missing to avoid deleting the db file?

like image 677
Olivier Pons Avatar asked Oct 19 '22 06:10

Olivier Pons


1 Answers

After changing your model you just do

python manage.py makemigrations your_app

And then migrate it with

python manage.py migrate

Doing this you dont have to delete your database. I hope this helpts you.. But dont forget run makemigrations after you apply changes to your model

like image 63
gamer Avatar answered Oct 22 '22 01:10

gamer