Google Cloud Run,Django和"no such table"构建期间



我遵循本教程将我在sqlite上本地运行的现有Django项目上传到Google Cloud Run/Postgres。

我运行了cloud_sql_proxy服务,可以登录Postgres。

我正在运行命令

gcloud builds submit --config cloudmigrate.yaml 
--substitutions _INSTANCE_NAME=INSTANCE_NAME,_REGION=REGION

它运行了一段时间,取得了良好的进展,但随后失败:

Step #2 - "apply migrations": django.db.utils.OperationalError: no such table: registration_setting
Finished Step #2 - "apply migrations"
ERROR
ERROR: build step 2 "gcr.io/google-appengine/exec-wrapper" failed: step exited with non-zero status: 1

我的注册应用程序中确实有一个设置表。但我不明白它是从哪里来的。这只是它试图创建的第一个表吗?我必须先做点什么才能让它在Postgres中创建初始表吗?当我检查Postgres时,我没有看到在其中创建任何表。

我试着清除迁移和pycache文件夹并重新创建它们。

我的项目中缺少这一部分的代码。

# Use django-environ to parse the connection string
DATABASES = {"default": env.db()}
# If the flag as been set, configure to use proxy
if os.getenv("USE_CLOUD_SQL_AUTH_PROXY", None):
DATABASES["default"]["HOST"] = "127.0.0.1"
DATABASES["default"]["PORT"] = 5432

最新更新