CircleCI test failing due to the “hstore” Postgres extension not being installed
我正在尝试进行一定的提交以通过CircleCI上的测试,但是我仍在尝试解决与本地环境的某些差异。这是
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | version: 2 jobs: build: working_directory: ~/lucy/lucy_web/ docker: - image: python:3.6.0 environment: DATABASE_URL: postgresql://my_app:my_password@localhost/my_db?sslmode=disable - image: jannkleen/docker-postgres-gis-hstore environment: POSTGRES_USER: my_app POSTGRES_DB: my_db POSTGRES_PASSWORD: my_password steps: - checkout - restore_cache: key: deps1-{{ .Branch }}-{{ checksum"lucy-web/requirements.txt" }} - run: name: Install Python deps in a venv command: | cd lucy-web python3 -m venv venv . venv/bin/activate pip3 install -r requirements.txt - save_cache: key: deps1-{{ .Branch }}-{{ checksum"lucy-web/requirements.txt" }} paths: -"venv" - run: command: | cd lucy-web source venv/bin/activate python manage.py compilescss --verbosity 0 python manage.py collectstatic --clear --no-input --verbosity 0 python manage.py makemigrations --no-input --verbosity 0 python manage.py migrate --no-input --verbosity 0 python manage.py test - store_artifacts: path: test-reports/ destination: tr1 - store_test_results: path: test-reports/ |
问题是由于
1 2 3 4 5 | django.db.utils.ProgrammingError: type"hstore" does not exist LINE 1: ...,"options" varchar(255)[] NOT NULL,"conditions" hstore NOT... ^ Exited with code 1 |
在我的本地计算机上,我先运行
1 2 3 4 5 6 7 8 9 10 11 12 13 | #!/bin/sh POSTGRES="gosu postgres" echo"******CREATING EXTENSIONS******" ${POSTGRES} psql -d postgres -c"UPDATE pg_database SET datallowconn = TRUE WHERE datname = 'template0';" ${POSTGRES} psql -d postgres -c"UPDATE pg_database SET datallowconn = TRUE WHERE datname = 'template1';" ${POSTGRES} psql -d template1 -c"CREATE EXTENSION IF NOT EXISTS hstore;" ${POSTGRES} psql -d template1 -c"CREATE EXTENSION IF NOT EXISTS postgis;" ${POSTGRES} psql -d template1 -c"CREATE EXTENSION IF NOT EXISTS postgis_topology;" echo"" echo"******DATABASE EXTENSIONS******" |
据我了解,如果扩展是在
如何解决此错误?
我遇到了类似的问题,这是我如何解决的。我的应用程序是节点应用程序,但基本思想应该相同。除了Postgres设置之外,我已经修剪了项目的所有特定内容。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | version: 2 jobs: build: docker: - image: circleci/postgres:10.3-alpine environment: - POSTGRES_USER: root - POSTGRES_PASS: test - POSTGRES_DB: circle-test steps: - checkout - run: name: Postgres Client command: sudo apt install postgresql-client - run: name: Stash the PG Password command: echo"test"> .pgpass - run: name: Waiting for PostgreSQL to start command: | for i in `seq 1 10`; do nc -z localhost 5432 && echo Success && exit 0 echo -n . sleep 2 done echo Failed waiting for Postgres && exit 1 - run: name: Enable hstore in Postgres command: psql -U root -d circle-test -h localhost -p 5432 -c"CREATE EXTENSION IF NOT EXISTS hstore;" |