我不得不修改我的应用程序的表,所以我从postgres数据库中删除了它(在django python shell中使用objectname.objects.all().delete()
,在PGAdmin中使用postgres)。
我删除了appname migrations
文件夹。当我运行python manage.py makemigrations appname
时,文件夹迁移是用0001_initial.py
创建表的。当我运行python manage.py migrate appname
时,什么也没发生,我在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.
当我删除文件夹migrations时,我可以看到迁移与python manage.py showmigrations
一起消失了。
我也尝试了python manage.py migrate --run-syncdb
,但仍然没有结果。
(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.
关于可能发生的事情有什么其他的想法吗?也许postgres的full_text_search索引搞砸了?关于如何在postgres中重新获得表有什么想法吗?
1条答案
按热度按时间72qzrwbm1#
您是否尝试过
python manage.py migrate appname zero
?它将迁移到在应用中创建任何模型之前的状态。https://docs.djangoproject.com/en/4.1/topics/migrations/#reversing-migrations