简体   繁体   English

Travis CI,Rails和Postgresql-错误类型hstore不存在

[英]Travis ci, Rails and Postgresql - ERROR type hstore does not exist

I'm getting: 我越来越:

PG::UndefinedObject: ERROR:  type "hstore" does not exist
LINE 1: ...arying(255), "finish" timestamp, "widget_locations" hstore) 

Below is my Travis config file: 以下是我的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

I also have below migrations file: 我也有下面的迁移文件:

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

This however creates the error regardless. 但是,这无论如何都会产生错误。

Is there something wrong here? 这里有什么问题吗?

Might be too late with this but encountered the same problem. 对此可能为时已晚,但遇到了相同的问题。 Changed hstore create to this: 将hstore create更改为此:

 - psql virtual_test -c 'CREATE EXTENSION IF NOT EXISTS hstore' -U postgres

And rake db:test:prepare to this: 和耙db:test:prepare为此:

 - RAILS_ENV=test bundle exec rake db:test:prepare

Its weird but it worked, might help you out as well. 它很奇怪,但是有效,可能也会对您有所帮助。

This is probably caused by a search_path issue as described in this answer: 这可能是由于此答案中所述的search_path问题引起的:

https://stackoverflow.com/a/21910573/179316 https://stackoverflow.com/a/21910573/179316

Change your before_script to this: 将您的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

Note that we're creating an extension on the first line. 请注意,我们正在第一行上创建扩展。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM