6

continuo a correre python manage.py makemigrations sul mio server Heroku, ma non importa quante volte l'eseguo ottengo:Django 1.7 makemigrations non avere un effetto

$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 

e se corro heroku run python manage.py migrate

ritorna con:

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. 

Certo, so solo abbastanza di Postgres e migrazioni di essere pericoloso, così ho pensato di chiedere qui. È già successo a qualcuno?

+0

Non si dovrebbero eseguire makemigrations sul server. Eseguilo localmente, aggiungi i file di migrazione creati a git e spingilo, e heroku eseguirà automaticamente la migrazione per te. –

risposta

7

Dopo la migrazione locale completato si dovrebbe avere file di migrazione (s) su <your django app>/migrations cartella Ex (RestAPI è mio Django applicazione qui):

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

così si dovrebbe impegnarsi file manualmente migrazioni:

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

Nota: NO heroku non eseguirà la migrazione sull'app automaticamente! Ho controllato questo! È consigliabile eseguire la migrazione per la tua app dopo aver premuto il file:

Heroku $ Heroku corsa python manage.py migrare RestAPI Esecuzione python manage.py migrate restapi collegato al terminale di ... up, run.4602 operazioni da eseguire: applicare tutte migrazioni: restapi Migrazioni in esecuzione: Applicazione di restapi.0001_initial ... OK

+0

Grazie per questa risposta. Mi stavo grattando la testa su questo problema perché il mio file di impostazioni rifletteva le impostazioni di heroku e non avevo ancora creato un altro file di impostazioni di sviluppo per eseguire le cose localmente e poi tornare a heroku. +1! –

Problemi correlati