I had to modify the table of my app so I dropped it from postgres database (using objectname.objects.all().delete()
in django python shell and with postgres at PGAdmin).
I deleted the appname migrations
folder. When I run python manage.py makemigrations appname
, the folder migrations gets created with a 0001_initial.py
creating the tables.
When I run python manage.py migrate appname
, nothing happens and I cannot see the tables in postgres PGAdmin.
(website) C:\Users\Folder>python manage.py makemigrations appname
Migrations for 'appname':
food\migrations\0001_initial.py
- Create model Table1
- Create model Table2
- Create index Table2_search__7dd784_gin on field(s) search_vector of model Table2
(website) C:\Users\Folder>python manage.py migrate
Operations to perform:
Apply all migrations: accounts, admin, auth, contenttypes, appname, sessions
Running migrations:
No migrations to apply.
When I deleted the folder migrations I can see the migrations are gone with python manage.py showmigrations
.
I also tried python manage.py migrate --run-syncdb
but still no result.
(website) C:\Users\Folder>python manage.py migrate --run-syncdb
Operations to perform:
Synchronize unmigrated apps: messages, postgres, staticfiles
Apply all migrations: accounts, admin, auth, contenttypes, appname, sessions
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Running migrations:
No migrations to apply.
Any other idea on what may be happening? Maybe postgres full_text_search index is messing it up? Any idea on how to get the tables in postgres again?
Have you tried python manage.py migrate appname zero
?
It will migrate to the state before creating any models in the app.
https://docs.djangoproject.com/en/4.1/topics/migrations/#reversing-migrations