gpt4 book ai didi

ruby-on-rails - Travis CI hstore 不存在错误

转载 作者:太空宇宙 更新时间:2023-11-03 16:27:24 25 4
gpt4 key购买 nike

我收到来自 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

发生这种情况是否有原因?

最佳答案

您的配置文件指向三个不同的数据库,“postgresql”、“postgres”和“virtual_test”。

将测试更改为使用“postgres”数据库,不要费心创建 virtual_test 数据库,并确保通过 psql -d postgres -U postgres -c 'CREATE 在正确的位置创建 hstore扩展 hstore;'

关于ruby-on-rails - Travis CI hstore 不存在错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22108581/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com