Joff
Joff

Reputation: 12177

Django not creating tables in Postgres db

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?

Upvotes: 3

Views: 4232

Answers (2)

user18997868
user18997868

Reputation: 11

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

Upvotes: 1

Joff
Joff

Reputation: 12177

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.

Upvotes: 3

Related Questions