使用structure.sql而不是schema.rb为MySQL配置公寓gem以创建新租户

使用structure.sql而不是schema.rb为MySQL配置公寓gem以创建新租户,mysql,ruby-on-rails,ruby,apartment-gem,Mysql,Ruby On Rails,Ruby,Apartment Gem,我需要在Rails应用程序中查看SQL和存储过程,所以我必须从schema.rb更改为structure.SQL。这是我在config/application.rb中的配置 config.active_record.schema_format = :sql Apartment.configure do |config| config.excluded_models = %w{ Company CommonField } config.tenant_names = lambda{ Com

我需要在Rails应用程序中查看SQL和存储过程,所以我必须从schema.rb更改为structure.SQL。这是我在
config/application.rb中的配置

config.active_record.schema_format = :sql
Apartment.configure do |config|
  config.excluded_models = %w{ Company CommonField }
  config.tenant_names = lambda{ Company.pluck(:subdomain) }
  # ==> PostgreSQL only options
  config.use_schemas = true

  # 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 respresented 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 = false
  # <== PostgreSQL only options
  config.prepend_environment = !Rails.env.production?
end
但是当我在seed.rb中为一个实体创建一个新记录时

Company.create(
        name: 'Google',
        subdomain: 'google'
      )
出错

my_project/db/schema.rb尚不存在

我不知道是什么问题。我是否错过了cofig中的某些内容,某些地方仍然需要schema.rb,或者我错过了一些rake任务命令?我刚用过

rake db:migrate db:test:prepare
关注这个博客

更新: 我使用的是
公寓gem
公司
实体是租户

这里是公寓.rb中的配置

config.active_record.schema_format = :sql
Apartment.configure do |config|
  config.excluded_models = %w{ Company CommonField }
  config.tenant_names = lambda{ Company.pluck(:subdomain) }
  # ==> PostgreSQL only options
  config.use_schemas = true

  # 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 respresented 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 = false
  # <== PostgreSQL only options
  config.prepend_environment = !Rails.env.production?
end
plant.configure do | config|
config.excluded_models=%w{Company CommonField}
config.tenant_names=lambda{Company.pull(:subdomain)}
#==>仅限PostgreSQL选项
config.use_schemas=true
#公寓可以强制使用原始SQL转储,而不是schema.rb
#创建新模式。
#当您在PostgreSQL中使用一些无法使用的额外功能时,请使用此选项
#反映在
#schema.rb,如物化视图等(仅适用于use\u schemas set
#是的)。
#(注意:此选项不使用db/structure.sql,它通过
#执行pg_转储)
#
#config.use\u sql=false

#你能提供完整的错误堆栈跟踪吗?