我开始了我的模特:
myapp.models.py
class MyModel(models.Model):
field_a = models.FloatField()
field_c = models.FloatField()
然后在我的新项目上运行./manage.py migrate
,这一切都很好:
Operations to perform:
Synchronize unmigrated apps: myapp
Apply all migrations: admin, contenttypes, auth, sessions
Synchronizing apps without migrations:
Creating tables...
Creating table myapp_mymodel
Installing custom SQL...
Installing indexes...
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying sessions.0001_initial... OK
然后我改变了我的模型:
class MyModel(models.Model):
field_a = models.FloatField()
field_b = models.FloatField()
field_c = models.FloatField()
我又跑了./manage.py migrate
,什么都没发生。
(project)$ ./manage.py migrate
Operations to perform:
Synchronize unmigrated apps: myapp
Apply all migrations: admin, contenttypes, auth, sessions
Synchronizing apps without migrations:
Creating tables...
Installing custom SQL...
Installing indexes...
Running migrations:
No migrations to apply.
我想知道我需要做些什么来让我的新应用程序迁移?
答案 0 :(得分:13)
Ack,回答了我自己的问题。
我需要做的是运行:
./manage.py makemigrations myapp
答案 1 :(得分:3)
如果已经运行 makemigrations 命令,如果发生这种情况,则需要检查迁移文件夹中是否存在 __ initial __。py 空文件。当我通过在测试远程服务器上运行创建迁移时,我曾经发生过一次事件,即使我已将所有创建的迁移复制到我的代码中,但我忘记复制占位符空文件,这有助于迁移命令识别具有迁移的应用程序运行
希望它有所帮助。