gpt4 book ai didi

ruby-on-rails - Gitlab-CI 和 Gem 公寓

转载 作者:行者123 更新时间:2023-11-29 14:03:21 25 4
gpt4 key购买 nike

我在尝试在我的 Rails 5.1 项目上设置 Gitlab CI 时遇到一个奇怪的问题,该项目使用 apartment gem 来支持 Multi-Tenancy 。我已经设置了 docker-compose 来构建我的容器并运行测试。他们正在我的本地机器上传递,但 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

我的 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

我的 gilab-ci.yml 看起来像 this 。我还有一个 lib/tasks/apartment.rake 任务设置为 this 应该在创建数据库时启用 hstore。任务通过 CI,但它仍然返回相同的错误。

最佳答案

错误:类型“hstore”不存在 此错误告诉您 hstore 扩展名不存在于您的 postgres 数据库中。
在任何地方使用此数据类型之前,您必须在迁移中启用它。

def change
enable_extension "hstore"
end

您必须确保数据库用户是 super 用户

关于ruby-on-rails - Gitlab-CI 和 Gem 公寓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44647701/

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