Ruby on rails Travis ci、Rails和Postgresql-错误类型hstore不存在
我得到:Ruby on rails Travis ci、Rails和Postgresql-错误类型hstore不存在,ruby-on-rails,ruby,postgresql,ruby-on-rails-4,travis-ci,Ruby On Rails,Ruby,Postgresql,Ruby On Rails 4,Travis Ci,我得到: PG::UndefinedObject: ERROR: type "hstore" does not exist LINE 1: ...arying(255), "finish" timestamp, "widget_locations" hstore) 下面是我的Travis配置文件: language: ruby rvm: - 2.0.0 env: - DB=postgresql script: - RAILS_ENV=test bundle exec rake
PG::UndefinedObject: ERROR: type "hstore" does not exist
LINE 1: ...arying(255), "finish" timestamp, "widget_locations" hstore)
下面是我的Travis配置文件:
language: ruby
rvm:
- 2.0.0
env:
- DB=postgresql
script:
- RAILS_ENV=test bundle exec rake db:migrate --trace
- bundle exec rake db:test:prepare
- bundle exec rspec spec/
before_script:
- cp config/database.travis.yml config/database.yml
- psql -c 'create database virtual_test' -U postgres
- psql virtual_test -c 'CREATE EXTENSION hstore' -U postgres
bundler_args: --binstubs=./bundler_stubs
before_install:
- bundle update debugger-ruby_core_source
我还有以下迁移文件:
class SetupHstore < ActiveRecord::Migration
def self.up
execute 'CREATE EXTENSION IF NOT EXISTS hstore'
end
def self.down
execute 'DROP EXTENSION IF EXISTS hstore'
end
end
class SetupHstore
然而,不管怎样,这都会产生错误
这里有什么问题吗?这样做可能太迟了,但遇到了同样的问题。将hstore create更改为:
- psql virtual_test -c 'CREATE EXTENSION IF NOT EXISTS hstore' -U postgres
和rake db:test:准备:
- RAILS_ENV=test bundle exec rake db:test:prepare
这很奇怪,但它起作用了,可能也会帮助您解决问题。这可能是由以下答案中描述的
搜索路径问题造成的:
将脚本之前的更改为:
before_script:
- psql template1 -c 'create extension hstore;'
- cp config/database.travis.yml config/database.yml
- psql -c 'create database virtual_test' -U postgres
请注意,我们正在第一行创建扩展。请尝试从psql
控制台启用hstore
:CREATE extension hstore
我已经有before\U script
命令“-psql virtual\U test-c”CREATE extension hstore'-U postgres`这可以吗?