How to erase/delete/wipe the migration history in Django

Question:

I’m experimenting with varios django modells and settings.

I can’t erase the migration history which is make me upset.

I have run this script and physically delete all .pyc files and the database.

del /s /q *.pyc
del /q db.sqlite3

After I typed:

python manage.py makemigrations

and I got this:

No changes detected

I tired this as well:

python manage.py migrate --fake-initial

no luck.

Obviously I have tried to delete all files under migrations folder even I deleted that folders as well.

Asked By: StJoesy

||

Answers:

With

del /q db.sqlite3

you’ve deleted your database (and all of the applied migrations there), which is all dandy, but the migrations themselves remain as Python files on disk (in <app>/migrations/*.py).

The

No changes detected

you get when you run makemigrations means there are no new migration files that would need to be created.

If you really want to get rid of all migrations, i.e. all of the history of your how models have evolved, you will also need to delete the migration script files under your apps’ migrations/ folders.

Answered By: AKX

Just delete all migrations folders in your app then run python manage.py makemigrations

Answered By: monim
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.