dsb*_*afe 5 database migration django postgresql heroku
我在 Django 中有一个应用程序,我在 heroku 中部署了它。部署运行良好,但我的模型的数据库没有迁移。
部署后,我再次本地运行:
python manage.py makemigrations
python manage.py migrate
Run Code Online (Sandbox Code Playgroud)
之后,我这样做:
heroku run python manage.py makemigrations
heroku run python manage.py migrate
Run Code Online (Sandbox Code Playgroud)
在我运行服务器并等待它运行良好之后:
heroku run python manage.py runserver
Run Code Online (Sandbox Code Playgroud)
我有 3 个模型:
客户、类别、产品
produto有一个ForeignKey到categoria。所以,本地,我有 3 个数据库:
produtos_produto, produtos_categoria, cliente.
我PostgreSQL在本地和heroku中用作数据库。
但是在 heroku 中,我没有任何这些数据库。
当我运行服务器时,在浏览器中我有以下答案:
ProgrammingError at /
relation "produtos_categoria" does not exist
LINE 1: ...ia"."descricao", "produtos_categoria"."logo" FROM "produtos_...
                                                             ^
Request Method:     GET
Request URL:    http://redewebsite.herokuapp.com/
Django Version:     1.9.2
Exception Type:     ProgrammingError
Exception Value:    
relation "produtos_categoria" does not exist
LINE 1: ...ia"."descricao", "produtos_categoria"."logo" FROM "produtos_...
                                                             ^
Exception Location:     /app/.heroku/python/lib/python2.7/site-packages/django/db/backends/utils.py in execute, line 64
Python Executable:  /app/.heroku/python/bin/python
Python Version:     2.7.11
Python Path:    
['/app',
 '/app/.heroku/python/bin',
 '/app/.heroku/python/lib/python2.7/site-packages/setuptools-19.6-py2.7.egg',
 '/app/.heroku/python/lib/python2.7/site-packages/pip-8.0.2-py2.7.egg',
 '/app',
 '/app/.heroku/python/lib/python27.zip',
 '/app/.heroku/python/lib/python2.7',
 '/app/.heroku/python/lib/python2.7/plat-linux2',
 '/app/.heroku/python/lib/python2.7/lib-tk',
 '/app/.heroku/python/lib/python2.7/lib-old',
 '/app/.heroku/python/lib/python2.7/lib-dynload',
 '/app/.heroku/python/lib/python2.7/site-packages']
Server time:    Sex, 4 Mar 2016 17:50:43 +0000
Run Code Online (Sandbox Code Playgroud)
    |   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           4553 次  |  
        
|   最近记录:  |