Pycharm:使移民和迁移忽略我的变化



这是我一直在做的事情,我想这不是正确的解决方案:

  • 修改我的模型
  • 删除db.sqlite3文件
  • 启动makemigrations,然后启动migrate

如果我删除db.sqlite3文件,当我尝试运行makemigrations然后migrate:

manage.py@pyweb > makemigrations
"C:Program Files (x86)JetBrainsPyCharm 4.5.3binrunnerw.exe" C:Python34python.exe "C:Program Files (x86)JetBrainsPyCharm 4.5.3helperspycharmdjango_manage.py" makemigrations C:/Users/Olivier/PycharmProjects/pyweb
No changes detected
Process finished with exit code 0
manage.py@pyweb > migrate
"C:Program Files (x86)JetBrainsPyCharm 4.5.3binrunnerw.exe" C:Python34python.exe "C:Program Files (x86)JetBrainsPyCharm 4.5.3helperspycharmdjango_manage.py" migrate C:/Users/Olivier/PycharmProjects/pyweb
Operations to perform:
  Synchronize unmigrated apps: staticfiles, messages, produits
  Apply all migrations: sessions, auth, contenttypes, admin
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  No migrations to apply.
Process finished with exit code 0

我错过了什么步骤来避免删除db文件?

更改模型后,您只需执行

python manage.py makemigrations your_app

然后用

python manage.py migrate

这样做你不必删除你的数据库。我希望这对你有所帮助。但是不要忘记在对模型应用更改后运行makemigration

相关内容

  • 没有找到相关文章

最新更新