[英]Travis ci, Rails and Postgresql - ERROR type hstore does not exist
我越來越:
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
但是,這無論如何都會產生錯誤。
這里有什么問題嗎?
對此可能為時已晚,但遇到了相同的問題。 將hstore create更改為此:
- psql virtual_test -c 'CREATE EXTENSION IF NOT EXISTS hstore' -U postgres
和耙db:test:prepare為此:
- RAILS_ENV=test bundle exec rake db:test:prepare
它很奇怪,但是有效,可能也會對您有所幫助。
這可能是由於此答案中所述的search_path
問題引起的:
將您的before_script
更改為此:
before_script:
- psql template1 -c 'create extension hstore;'
- cp config/database.travis.yml config/database.yml
- psql -c 'create database virtual_test' -U postgres
請注意,我們正在第一行上創建擴展。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.