使用postgres扩展在Heroku CI上运行Django测试

问题描述

概述

我有一个部署在Heroku上并使用Heroku Postgres附加组件作为数据库的应用程序。我使用PostGIS和Hstore扩展来存储地理和Hstore(键值对)数据。

问题陈述

我正在配置Heroku CI以运行测试用例。当Django应用程序在测试运行期间创建测试数据库时,我需要为其提供一个数据库。但是我知道Heroku的In-dyno database does not support postgis and hstore extension。因此,我为其提供了免费的 hobby-dev heroku postgres插件。现在我得到以下错误
Got an error creating the test database: permission denied to create database

下面是我的app.json配置:

{
  "environments": {
    "test": {
      "scripts": {
        "test-setup": "pip install -r requirements.txt","test": "python manage.py test -v 2 --noinput"
      },"addons": [
        "heroku-postgresql:hobby-dev","heroku-redis:in-dyno"
      ],"buildpacks": [
        {
          "url": "heroku/python"
        },{
          "url": "https://github.com/heroku/heroku-geo-buildpack"
        }        
      ]
    }
  }
}

此处的关键问题是:

  1. 是否建议使用dyno Postgres或将其作为附件提供?
  2. 如果在dyno Postgres中,如何安装扩展?
  3. 如果作为附件,如何使用预配置的数据库运行Django测试? (因为它不允许我创建测试数据库

我们非常感谢您的帮助/建议。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)