Ruby on rails 公寓gem-不创建表postgresql
RailsRuby on rails 公寓gem-不创建表postgresql,ruby-on-rails,apartment-gem,Ruby On Rails,Apartment Gem,Rails5.x,postgres,公寓gem 只有以下两个表是在公寓::租户.create('microsoft')时创建的。其他20个表未创建,仍在公共架构中microsoft已创建架构,但未创建表 这是我的公寓。rb config.excluded_models = %w{ Account } config.active_record.schema_format = :sql 及租客姓名 config.tenant_names = lambda { Account.pluck :do
5.x
,postgres,公寓
gem
只有以下两个表是在公寓::租户.create('microsoft')时创建的。
其他20个表未创建,仍在公共架构中<代码>microsoft已创建架构,但未创建表
这是我的公寓。rb
config.excluded_models = %w{ Account }
config.active_record.schema_format = :sql
及租客姓名
config.tenant_names = lambda { Account.pluck :domain }
使用模式
config.use_schemas = true
当我使用rakedb:migrate
时,它不会在schema.rb上创建任何内容,而我使用公寓创建了一个新的应用程序。它将在schema.rb内生成另一组迁移。
例如:
create_table“companys”,force::cascade do | t |
请检查初始化器中的plant.rb
文件
确认新租户已配置。如果你有一个静态数组,你需要扩展它
config.tenant_names = ['tenant1', 'myothertenant', 'microsoft']
通过向配置中添加lambda,也可以使其成为动态的:
config.tenant_names = lambda { some_tenant_loading_func }
同时检查您是否设置了pg特定选项:
config.use_schemas = true
此选项指定是使用PostgreSQL架构还是为每个租户创建新数据库。
sql
format enabledconfig/application.rb
config.excluded_models = %w{ Account }
config.active_record.schema_format = :sql
如公寓配置中所述
公寓可以强制使用原始SQL转储而不是schema.rb来创建新的架构。
当您在PostgreSQL中使用某些无法在中表示的额外功能时,请使用此选项
schema.rb,如物化视图等(仅适用于将use\u schemas设置为true的情况)。
(注意:此选项不使用db/structure.sql,它通过执行pg_dump创建sql转储)
修正了这个问题