3

So I did some changing around of what is a primary key in my models and django did not like that. I did some reading about why and came up with a complicated solution, that involved creating intermediary tables and then pushing all the data to a final version with they new primary key.

I thought 'Hey, I just have junk test data in there anyway, ill just drop the tables I want to change, delete all the migration history and then re-migrate them over...'

Well I tried that and now Django is running the initial migration and putting it in the migration folder, but when I actually run

python manage.py migrate

I get this output:

Operations to perform:
  Synchronize unmigrated apps: staticfiles, messages
  Apply all migrations: sessions, admin, study, auth, quiz, contenttypes, main
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  No migrations to apply.

and my database is still missing the tables I wanted to recreate. Am I missing something here? It should recreate them in my db, right? How do I get it to do this?

3
  • Are there any tables still in the database? When django migrates, it creates some support tables that aren't part of your app. If those are still around they may be confusing the framework. Commented Oct 8, 2015 at 2:53
  • How about python manage.py makemigrations and then python manage.py migrate ? Commented Oct 8, 2015 at 3:06
  • Try just running the migration for a specific app: python manage.py migrate quiz Commented Oct 8, 2015 at 3:10

2 Answers 2

3

The problem was that in the database, there is a table called django_migrations which keeps a record of applied migrations. I believe that's what eykanal was referring to in the comments. Once I deleted the respective lines and the remaining tables from my app, it created all new ones.

Sign up to request clarification or add additional context in comments.

Comments

1

i have faced the same issue i just went into django_migrations in postgres then deleted my application table. refer the screen shot then its worked enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.