Rails 5.x
, postgres , apartment
gem
only below two tables created when Apartment::Tenant.create('microsoft')
other 20 tables are not created, still in public schemas. microsoft
schema created but not tables
Here is my apartment.rb
config.excluded_models = %w{ Account }
and tenant names
config.tenant_names = lambda { Account.pluck :domain }
use schemas
config.use_schemas = true
when I do rake db:migrate
it is not creating anything on schema.rb whereas I created a new app with apartment. its generating another set of migration inside schema.rb.
eg: create_table "companies", force: :cascade do |t|
sql
format enabled config/application.rb
config.active_record.schema_format = :sql
as mentioned in the apartment config,
Apartment can be forced to use raw SQL dumps instead of schema.rb for creating new schemas. Use this when you are using some extra features in PostgreSQL that can't be represented in schema.rb, like materialized views etc. (only applies with use_schemas set to true). (Note: this option doesn't use db/structure.sql, it creates SQL dump by executing pg_dump)
config.use_sql = true
fixed the issue.