How to reset migrations in Django 1.7
I would just do the following on both the environments (as long as the code is the same)
- Delete your migrations folder
- DELETE FROM django_migrations WHERE app =
<your app name>
. You could alternatively just truncate this table. python manage.py makemigrations
python manage.py migrate --fake
After this all your changes should get detected across environments.
Run
python manage.py migrate your_app zero
This will drop all tables from your_app
If you want, since you said you want to start over, you can delete your migrations folder, or maybe rename the folder, create a new migrations folder and run
python manage.py makemigrations your_app
python manage.py migrate your_app
Just like south, you can always go back and forth...
# Go to the first migration
python manage.py migrate your_app 0001
# Go to the third migration
python manage.py migrate your_app 0003
So imagine that your 4th migration is a mess... you can always migrate to the 3rd, remove the 4th migration file and do it again.
Note:
This one of the reasons your models should be in different apps. Say you have 2 models : User and Note. It's a good practice to create 2 apps: users and notes so the migrations are independent from each other.
Try not use a single application for all your models
A minor variation on harshil's answer:
$ manage.py migrate --fake <appname> zero
$ rm -rf migrations
$ manage.py makemigrations <appname>
$ manage.py migrate --fake <appname>
This will ...
- pretend to rollback all of your migrations without touching the actual tables in the app
- remove your existing migration scripts for the app
- create a new initial migration for the app
- fake a migration to the initial migration for the app