[英]Gitlab-CI and Apartment Gem
I'm experiencing a strange problem while trying to set up Gitlab CI on my Rails 5.1
project wich uses apartment
gem for multitennancy support. 尝试在我的Rails 5.1
项目中设置Gitlab CI时遇到一个奇怪的问题,该问题使用apartment
gem提供多租户支持。 I've got docker-compose set up to build my containers and run tests. 我已经设置了docker-compose来构建我的容器并运行测试。 And they are passing on my local machine, but Gitlab pipelines keep failing with this error. 它们正在我的本地计算机上传递,但是Gitlab管道始终因该错误而失败。
$ bundle exec rspec
/builds/demiurge/new_world/spec/models/char/skill_spec.rb:5: warning: toplevel constant Skill referenced by Char::Skill
Run options: include {:focus=>true}
All examples were filtered out; ignoring {:focus=>true}
An error occurred in a `before(:suite)` hook.
Failure/Error: Apartment::Tenant.create slug
ActiveRecord::StatementInvalid:
PG::InFailedSqlTransaction: ERROR: current transaction is aborted, commands ignored until end of transaction block
: SET search_path TO "public", "shared_extensions"
# ./app/models/world.rb:36:in `create_tenant'
# ./spec/rails_helper.rb:52:in `block (2 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# PG::UndefinedObject:
# ERROR: type "hstore" does not exist
# LINE 1: ...har_id" integer, "type" character varying, "data" hstore, "p...
# ^
# ./db/schema.rb:292:in `block in <top (required)>'
Finished in 0.58676 seconds (files took 5 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples
My docker-compose setup is simple: 我的docker-compose设置很简单:
cache:
image: redis:alpine
ports:
- 6379:6379
db:
image: postgres:9.6-alpine
volumes:
- ./data/db/data:/var/lib/postgresql/data
ports:
- 5432:5432
And my gilab-ci.yml looks like this . 我的gilab-ci.yml看起来像这样 。 And I also have a lib/tasks/apartment.rake
task set up like this that is supposed to enable hstore on DB creation. 我还设置了一个lib/tasks/apartment.rake
任务, 该任务应该在数据库创建时启用hstore。 The task passes on CI, but it still returnes the same error. 任务通过CI,但仍返回相同的错误。
ERROR: type "hstore" does not exist
This error tells you that the hstore
extension is not present on your postgres database. ERROR: type "hstore" does not exist
此错误告诉您在postgres数据库中不存在hstore
扩展名。
You have to enable it in a migration before using this datatype anywhere. 您必须在迁移中启用它,然后才能在任何地方使用此数据类型。
def change
enable_extension "hstore"
end
You have to ensure that the database user is a superuser
您必须确保数据库用户是superuser
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.