【发布时间】:2018-03-06 17:37:46
【问题描述】:
每次我更改列名或长度或其他任何内容时,我都需要将整个数据库放到 heroku 中。这是在执行makemigrations 和migrate 之后。在本地,它工作正常。我不需要调整。在heroku上,它已经到了我无法继续重置的地步。我使用heroku pg:reset DATABASE_URL 重置。
还有什么方法可以让我在每次调整时都不需要删除整个数据库?
[[编辑]]
DATABASES = {
"default": {
# Add "postgresql_psycopg2", "mysql", "sqlite3" or "oracle".
"ENGINE": "django.db.backends.postgresql",
# DB name or path to database file if using sqlite3.
"NAME": "name",
# Not used with sqlite3.
"USER": "uesrname",
# Not used with sqlite3.
"PASSWORD": "password",
# Set to empty string for localhost. Not used with sqlite3.
"HOST": "xxxxxxxxxx.compute-1.amazonaws.com",
# Set to empty string for default. Not used with sqlite3.
"PORT": "5432",
}
}
【问题讨论】:
-
迁移的全部意义在于它们对您的数据库进行增量更改,因此您无需删除它。只需运行迁移。