2016-06-08 84 views
1

我的項目託管在Heroku最近我想換一列 的大小分貝 但運行makemigrations命令後,然後遷移命令時,它給出了一個錯誤,我不想失去我的數據。如何解決在heroku上託管的django項目中的遷移問題?

H:\shuboy2014>heroku run python manage.py makemigrations posts 
    Running python manage.py makemigrations posts on shuboy2014... up, run.9067 
    Migrations for 'posts': 
    0003_auto_20160608_1404.py: 
     - Alter field slug on post  

    H:\shuboy2014>heroku run python manage.py migrate 
    Running python manage.py migrate on shuboy2014... up, run.3731 
    Operations to perform: 
    Apply all migrations: admin, contenttypes, posts, sessions, auth 
    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. 

任何有用的建議將是可觀的。

+0

您確定您的更改已反映在遷移文件中嗎? – AndreyT

+0

但我如何才能在heroku上查看它? – shuboy2014

+0

無論如何,您應該將遷移文件提交到您的源代碼管理,我不確定您在這裏問的是什麼 – Sayse

回答

3

heroku run命令上一次性DYNOS有一個短暫的文件系統中運行,所以你生成被立即銷燬的文件系統上的遷移文件。

您應該在本地生成遷移,提交併推送它們,然後執行heroku run python manage.py migrate命令。

1

我就跑makemigrations我的本地計算機上遷移命令,然後將其推在Heroku上,並再次運行命令和它的完成。

H:\shuboy2014>heroku run python manage.py migrate 
Running python manage.py migrate on shuboy2014... up, run.6192 
Operations to perform: 
    Apply all migrations: contenttypes, auth, posts, sessions, admin 
Running migrations: 
    Rendering model states... DONE 
    Applying posts.0003_auto_20160608_2001... OK