2

I've dropped my Postgres database by accident. Then as per this solution I deleted the migration files but now can't execute the third step's command "python manage.py migrate --fake".

RuntimeError: Error creating new content types. 
Please make sure contenttypes is migrated before trying to migrate apps individually.


psycopg2.ProgrammingError: relation "django_content_type" does not exist
LINE 1: ..."."app_label", "django_content_type"."model" FROM "django_co...
                                                         ^

I tried running "python manage.py migrate contenttypes" and "python manage.py makemigrations contenttypes --empty" but neither work.

Using django 1.9.5

Community
  • 1
  • 1
Naarkie
  • 351
  • 1
  • 2
  • 10

1 Answers1

-1

Synchronise your project first: like this:

python manage.py syncdb

when finish you can run: python manage.py makemigrations and last python manage.py migrate

Mbambadev
  • 729
  • 1
  • 7
  • 26
  • `python manage.py syncdb` returns "Unknown command: 'syncdb'". I tried doing `python manage.py migrate --run-syncdb` but that returned the exact same thing as just "migrate" – Naarkie Apr 24 '16 at 16:27
  • wath django version you have ? – Mbambadev Apr 24 '16 at 17:10
  • I'm using Django 1.9.5 – Naarkie Apr 24 '16 at 18:35
  • If you have django 1.9 use makemigrations like this: python manage.py makemigrations; syncdb removed in 1.9 you must use makemigrations and migrate (python manage.py migrate). Don't forget add s in makemigrations command. – Mbambadev Apr 24 '16 at 19:59
  • Yes I've done the standard makemigrations and then migrate. After makemigrations I get "no changes detected" and after migrate I get the contenttypes error like in my original post – Naarkie Apr 25 '16 at 08:21
  • `syncdb` was deprecated in Django 1.7, this answer was outdated when it was posted, and certainly is now. See ["Unknown command syncdb" running "python manage.py syncdb"](//stackoverflow.com/q/28685931) – Martijn Pieters Oct 24 '18 at 16:10