我已经设置了架构文件,但无法为租户定义种子文件,以便它只能为租户迁移运行。此外,一旦创建了用户并创建了租户,我也会尝试创建模式。
require 'apartment/elevators/subdomain'
#
# Apartment Configuration
#
Apartment.configure do |config|
config.excluded_models = ["Admin","Contractor", "ContractorPackage","ContractorTransaction","Country","Currency","Faq","FaqCategory","Language","Package","Page","PaymentType","Setting","TempTransaction","Testimonial","Timezone","Tutorial"]
# use postgres schemas?
config.use_schemas = true
config.tenant_names = lambda{ Contractor.pluck("CONCAT('contractor_',id)") }
end
# overriding module schema file here
module Apartment
class << self
def database_schema_file
@database_schema_file=Rails.root.join('db', 'contractor_schema.rb')
end
end
end
Rails.application.config.middleware.use 'Apartment::Elevators::Subdomain'