jpdstan
jpdstan

Reputation: 69

How to delete existing migrations in Django 1.7

So i'm following the Tango with Django guide, specifically part 7.3.2. of the tutorial. After I ran the command python3 manage.py makemigrations rango, it won't let me re-populate the database using the populate script. Instead I got the error: django.db.utils.OperationalError: no such column: rango_category.slug.

Then, I tried to revert things back to normal by deleting all the slug code (so before 7.3 of the guide). I made a migration after doing so, but then because the prior migration which added the slug category was never deleted, I can't use the migrate command to revert my changes because it throws an error when it tries to migrate using the old Added category slug migration. Even when I specifically point to the newest migration, it still gives me an error for the old one.

Then, in an effort to fix things, I used a bunch of different migrate and makemigrations commands, including --empty, --fake, squashmigrations etc and now my migrations look unrecognizable. Is there a way to just delete all these existing migrations and just start from a completely clean slate?

This is what migrate --list looks like now, for reference:

admin [ ] 0001_initial auth [ ] 0001_initial rango [ ] 0001_squashed_0003_category_slug (3 squashed migrations) [ ] 0001_squashed_0005_auto_20150328_0917 (5 squashed migrations) contenttypes [ ] 0001_initial sessions [ ] 0001_initial

Upvotes: 1

Views: 407

Answers (2)

Jaakko
Jaakko

Reputation: 584

You don't need to delete the migrations folder, only the migrations files, but leave __init__.py there.

Upvotes: 1

itzMEonTV
itzMEonTV

Reputation: 20339

For a clean start.

  • Delete the migrations folder inside rango
  • delete database which created.Then restart your migration process

Upvotes: 1

Related Questions