我postgis
在 Heroku 上使用我的数据库的扩展。在生产中,这工作得很好;我像老板一样映射。
但是,我无法让我的应用程序在 HerokuCI 上构建,因为测试环境中的数据库插件没有安装 GDAL(postgis 扩展的一部分):
django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal", "GDAL", "gdal2.3.0", "gdal2.2.0", "gdal2.1.0", "gdal2.0.0", "gdal1.11.0"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
-----> test command `python manage.py migrate --noinput && python manage.py test` failed with exit status 1
我不知道如何在 heroku CI 环境中创建扩展。Heroku 的应用程序 json 模式没有说明如何在测试数据库上创建扩展。
我知道我不能将 in-dyno 数据库用于 CI,因为postgis 不是可用的扩展,但我没有使用 in-dyno 数据库,我正在使用计划......
这是我的应用架构:
{
"name": "mymegaapp",
"scripts": {
"heroku-prebuild": "create extension postgis",
"heroku-postbuild": "echo heroku-postbuild script runs here."
},
"env": {
},
"formation": {
},
"addons": [
],
"buildpacks": [
{
"url": "heroku/python"
},
{
"url": "heroku/nodejs"
}
],
"environments": {
"test": {
"scripts": {
"test": "python manage.py migrate --noinput && python manage.py test"
},
"env": {
"DJANGO_DEBUG": "1"
},
"addons":[
{
"plan": "heroku-postgresql",
"options": {
"version": "11"
}
},
"heroku-redis:hobby-dev"
]
}
}
}
请注意,我已尝试在预构建脚本中创建 postgis 扩展,但这并没有什么不同。
我还尝试在测试脚本之前调用创建:
"scripts": {
"test": "heroku create extension postgis && python manage.py migrate --noinput && python manage.py test"
},
这不起作用,因为在测功机中没有安装heroku cli。
关键问题:
- 如何在 HerokuCI 中创建扩展?
- 在 HerokuCI 中,postgis 是一个允许的扩展吗?