我从Travis那里得到以下错误:
The command "RAILS_ENV=test bundle exec rake db:migrate --trace" exited with 0.
$ bundle exec rake db:test:prepare
rake aborted!
PG::UndefinedObject: ERROR: type "hstore" does not exist
LINE 1: ...arying(255), "finish" timestamp, "widget_locations" hstore)
^
: CREATE TABLE "webcasts" ("id" serial primary key, "name" character varying(255), "hall_id" integer, "webcast_type" character varying(255), "media_type" character varying(255), "user_id" integer, "details" character varying(255), "template_id" integer, "background_colour" character varying(255), "created_at" timestamp, "updated_at" timestamp, "start" timestamp, "duration" character varying(255), "finish" timestamp, "widget_locations" hstore)
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `exec'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `block in execute'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:425:in `block in log'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:420:in `log'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:127:in `execute'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:190:in `create_table'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/migration.rb:625:in `block in method_missing'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/migration.rb:597:in `block in say_with_time'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/migration.rb:597:in `say_with_time'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/migration.rb:617:in `method_missing'
/home/travis/build/commstrat/virtual_exhibition/db/schema.rb:481:in `block in <top (required)>'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/schema.rb:42:in `instance_eval'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/schema.rb:42:in `define'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/schema.rb:62:in `define'
/home/travis/build/commstrat/virtual_exhibition/db/schema.rb:14:in `<top (required)>'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `block in load'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:253:in `block (3 levels) in <top (required)>'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:327:in `block (3 levels) in <top (required)>'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:316:in `block (3 levels) in <top (required)>'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:367:in `block (3 levels) in <top (required)>'
/home/travis/.rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `eval'
/home/travis/.rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:schema:load
(See full trace by running task with --trace)
我已经设置了以下迁移:
class SetupHstore < ActiveRecord::Migration
def self.up
execute 'CREATE EXTENSION hstore'
end
def self.down
execute 'DROP EXTENSION hstore'
end
end
由于它不起作用,我还添加了CREATE EXTENSION hstore
与belo 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 -c 'CREATE EXTENSION hstore' -U postgres
bundler_args: --binstubs=./bundler_stubs
before_install:
- bundle update debugger-ruby_core_source
为什么会发生这种情况?
答案 0 :(得分:1)
您的配置文件指向三个不同的数据库,“postgresql”,“postgres”和“virtual_test”。
更改您的测试以使用“postgres”数据库,不要打扰创建virtual_test数据库,并确保通过psql -d postgres -U postgres -c 'CREATE EXTENSION hstore;'
答案 1 :(得分:0)
将您的<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
<sources>
<source>src/main/resources/xsd</source>
</sources>
</configuration>
</plugin>
</plugins>
</build>
更改为:
xjc
请注意,我们在第一行添加了扩展程序。