Here's what I'm doing all the time, and I guess it's not the right solution:
db.sqlite3
filemakemigrations
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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With