【问题标题】:Django - reverting an un applied migrationDjango - 恢复未应用的迁移
【发布时间】:2023-03-14 14:10:01
【问题描述】:

我跑错了:

python manage.py schemamigration auth --initial 

并立即得到:

 + Added model auth.Permission
 + Added unique constraint for ['content_type', 'codename'] on auth.Permission
 + Added model auth.Group
 + Added M2M table for permissions on auth.Group
 + Added model auth.User
 + Added M2M table for groups on auth.User
 + Added M2M table for user_permissions on auth.User
Created 0001_initial.py. You can now apply this migration with: ./manage.py migrate auth

由于我不想迁移django.contrib.auth 我如何恢复它?

【问题讨论】:

    标签: django django-south


    【解决方案1】:

    它刚刚创建了迁移文件,但您还没有通过运行命令./manage.py migrate auth 应用这些迁移(确保您没有这样做)。所以手动删除迁移文件是安全的。

    【讨论】:

    • 我无法(干净地)访问它们,这是 LIB 中的某个地方,因为这是贡献。
    • 是的,我知道这是贡献。但是你找不到包然后去auth模块并删除迁移文件夹,有什么困难?
    • 转到 django shell 并输入 import django.contrib.auth as auth_module 然后 print auth_module.__file__ 为您提供模块路径。
    猜你喜欢
    • 2015-05-06
    • 2018-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-14
    • 1970-01-01
    相关资源
    最近更新 更多