There are already similar questions for South, but I have started my project with Django 1.7 and am not using South.
During development a lot of migrations have been created, however the software is not yet delievered and there exists no database that must be migrated. Therefore I would like to reset the migrations as if my current model was the original one and recreate all databases.
What is the recommended way to do that?
EDIT: As of Django 1.8 there is a new command named squashmigrations which more or less solves the problem described here.
I just had the same problem. Here's my workaround.
The
find
command: http://unixhelp.ed.ac.uk/CGI/man-cgi?findIf you're in development mode and you just want to reset everything (database, migrations, etc), I use this script based on Abdelhamid Ba's answer. This will wipe the tables of the database (Postgres), delete all migration files, re-run the migrations and load my initial fixtures:
reset-db.sql file:
migration.sh file:
load_initial_fixtures.sh file:
Just be sure to change the paths to corresponds to your app. I personally have these scripts in a folder called project_root/script/local, and django's sources are in project_root/src.
cd to src directory
cd /path/to/src
delete migration directories
rm -rf your_app/migrations/
note that this should be done for each app separately
migrate
python3.3 manage.py migrate
if you wish to start again
python3.3 manage.py makemigrations your_app
I got this. I just figured this out and it is good.
First, to clear migrations table:
Remove
app-name/migrations/
folder or contents.Make the migrations:
Finally tidy up your migrations without making other database changes:
A simple way is
Go to every app and delete the migration files.
Then go to the django-migrtaions table in the database and truncate it(delete all entries).
After that you can create migrations once again.
In the Django 1.7 version of migrations the reset functionality that used to be in South has been dropped in favor of new functionality for 'squashing' your migrations. This is supposed to be a good way to keep the number of migrations in check.
https://docs.djangoproject.com/en/dev/topics/migrations/#squashing-migrations
If you still want to really start from scratch i assume you still could by emptying the migrations table and removing the migrations after which you would run
makemigrations
again.