我把一切都建立在我的本地環境和Heroku的服務器上我的網站了代碼,我只是有嚴重的麻煩架構遷移到PostgreSQL數據庫上Heroku服務器。每當我試圖heroku run python manage.py migrate
,我得到以下(這將是一個初始遷移):故障遷移數據庫模式的Heroku(Postgres的)
Running python manage.py migrate on baseballstatview... up, run.1653 (Free)
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions, statview
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying sessions.0001_initial... OK
Applying statview.0001_initial... OK
這似乎不錯,但然後使用heroku pg:info
它告訴我,我有0表,進一步當我運行heroku run python manage.py showmigrations
這就是我得到:
Running python manage.py showmigrations on baseballstatview... up, run.5059 (Free)
admin
[ ] 0001_initial
[ ] 0002_logentry_remove_auto_add
auth
[ ] 0001_initial
[ ] 0002_alter_permission_name_max_length
[ ] 0003_alter_user_email_max_length
[ ] 0004_alter_user_username_opts
[ ] 0005_alter_user_last_login_null
[ ] 0006_require_contenttypes_0002
[ ] 0007_alter_validators_add_error_messages
[ ] 0008_alter_user_username_max_length
contenttypes
[ ] 0001_initial
[ ] 0002_remove_content_type_name
sessions
[ ] 0001_initial
statview
[ ] 0001_initial
所以看來,遷移不會通過,我想知道爲什麼是這樣的話。該數據庫是空的,我試着重置它,並再次嘗試,但似乎沒有任何工作。
編輯:下面是dj_database_url相關settings.py
:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mlb_data',
'USER': 'postgres',
'PASSWORD': 'pw',
'HOST': 'localhost',
'PORT': '5432',
}
}
import dj_database_url
DATABASES['default'] = dj_database_url.config()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
ALLOWED_HOSTS = ['*']
DEBUG = False
try:
from .local_settings import *
except ImportError:
pass
如何你的數據庫中定義?你在使用['dj-database-url'](https://github.com/kennethreitz/dj-database-url)嗎? – Chris
@Chris是的,我是 –
你有什麼local_settings?它是否覆蓋數據庫設置? –