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

相關問題