Ruby ActiveRecord::迁移-在另一个架构中引用表

Ruby ActiveRecord::迁移-在另一个架构中引用表,ruby,activerecord,migration,schema,Ruby,Activerecord,Migration,Schema,我正在使用Ruby和PostgreSQL,并创建了3种不同的DB模式:billing(用于计费相关数据)、customer(用于客户相关数据)和edocs(用于电子文档相关数据)。 我没有使用Rails,所以我有一个独立的迁移代码,如下所示: #migrate.rb if ARGV[0] =~ /VERSION=\d+/ version = ARGV[0].split('=')[1].to_i else version = nil end ActiveRecord::Base.def

我正在使用Ruby和PostgreSQL,并创建了3种不同的DB模式:billing(用于计费相关数据)、customer(用于客户相关数据)和edocs(用于电子文档相关数据)。 我没有使用Rails,所以我有一个独立的迁移代码,如下所示:

#migrate.rb

if ARGV[0] =~ /VERSION=\d+/
  version = ARGV[0].split('=')[1].to_i
else
  version = nil
end

ActiveRecord::Base.default_timezone           = :utc
@logger                                       = Logger.new $stderr
ActiveRecord::Base.logger                     = @logger
ActiveSupport::LogSubscriber.colorize_logging = false
@config                                       =     YAML.load_file(File.join(File.dirname(__FILE__), 'database.yml'))

ActiveRecord::Base.establish_connection(@config["edocs"])
ActiveRecord::Migrator.migrate(".", version)
我已经意识到,我可能必须创建不同的目录来包含不同模式的迁移,并更改每个migrate.rb的连接信息

但我不确定如何使一个表引用另一个模式中的另一个表。 例如:

class CreateBillingEventsTable < ActiveRecord::Migration

 def self.up
   create_table :billing_events do |t|
     t.references :customer, :null => false
     t.references :service_type, :null => false
     t.timestamps
   end
   change_table :billing_events do |t|
     t.index [:customer_id, :created_at]
   end
 end

 def self.down
   remove_index :billing_events, :column => [:customer_id, :created_at]
   drop_table :billing_events
 end

end
class CreateBillingEventsTablefalse
t、 引用:服务类型:null=>false
t、 时间戳
终止
更改表格:计费事件不可更改|
t、 索引[:客户标识,:创建时]
终止
终止
def自动关闭
删除索引:计费事件:列=>[:客户\u id,:创建的\u地址]
drop_表:计费_事件
终止
终止
在上面的示例中,“客户”和“账单事件”处于不同的模式中。 我该如何编写代码

谢谢