6

我把我的Heroku服务器上运行python manage.py makemigrations,但无论:的Django 1.7 makemigrations没有多少次我运行它,我得到一个效果

$heroku run python manage.py makemigrations 
Running `python manage.py makemigrations` attached to terminal... up, run.2680 
Migrations for 'default': 
    0002_auto_20141120_2007.py: 
    - Alter field user on usersocialauth 

,如果我跑heroku run python manage.py migrate

它回来搭配:

Running `python manage.py migrate` attached to terminal... up, run.1285 
Operations to perform: 
    Synchronize unmigrated apps: baflist_core, rest_framework, localflavor, storages 
    Apply all migrations: admin, userAccount, contenttypes, sessions, default, location, messaging, forum, auth, posts 
Synchronizing apps without migrations: 
    Creating tables... 
    Installing custom SQL... 
    Installing indexes... 
Running migrations: 
    No migrations to apply. 
    Your models have changes that are not yet reflected in a migration, and so won't be applied. 
    Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them. 

诚然,我只知道有足够的了解的Postgres和迁移是危险的,所以我想我会问放在这里。有没有人遇到过这个?

+0

您不应该在服务器上运行makemigrations。在本地运行它,将创建的迁移文件添加到git中,然后推送它,并且heroku会自动为您迁移 – 2014-11-20 21:53:09

回答

7

后局部迁移完成后,您应该<your django app>/migrations文件夹EX(RESTAPI是我的Django应用程序在这里)有迁移文件(S):

/Django/app/folder/restapi/migrations$ ls 
0001_initial.py 0001_initial.pyc __init__.py __init__.pyc 

所以,你应该提交迁移手动档:

heroku$ git commit restapi/migrations/0001_initial.py -m "migrations file" 
heroku$ git push heroku master 

注意:NO heroku不会自动运行在您的应用程序上!我已经检查过了! 您应该运行迁移你的应用程序,你推后的文件:

的Heroku $ Heroku的执行python manage.py迁移RESTAPI 运行python manage.py migrate restapi连接到终端...起来,run.4602 操作执行: 应用所有迁移:restapi 正在运行迁移: 应用restapi.0001_initial ...好吧

+0

谢谢你的回答。我在这个问题上摸不着头脑,因为我的设置文件反映了heroku设置,并且我还没有创建另一个dev设置文件在本地运行,然后推回到heroku。 +1! – 2015-03-26 00:42:05

相关问题