2010-02-17 20:48:43 +00:00
|
|
|
require 'active_record'
|
2009-03-04 04:53:21 +00:00
|
|
|
|
2010-05-25 17:21:45 +00:00
|
|
|
["two","one"].each do |db|
|
|
|
|
ActiveRecord::Base.establish_connection(:adapter => "#{"jdbc" if defined?(JRUBY_VERSION)}sqlite3", :database => "#{DB_DIR}/activerecord_#{db}.db")
|
|
|
|
ActiveRecord::Base.connection.execute('DROP TABLE IF EXISTS "widgets"')
|
|
|
|
ActiveRecord::Base.connection.execute('DROP TABLE IF EXISTS "another_widgets"')
|
2010-05-18 06:50:20 +00:00
|
|
|
|
|
|
|
ActiveRecord::Schema.define(:version => 1) do
|
|
|
|
create_table :widgets do |t|
|
|
|
|
t.string :name
|
|
|
|
end
|
2010-05-25 17:21:45 +00:00
|
|
|
|
2010-05-18 06:50:20 +00:00
|
|
|
create_table :another_widgets do |t|
|
|
|
|
t.string :name
|
|
|
|
end
|
2010-05-16 21:26:09 +00:00
|
|
|
end
|
2010-05-25 17:21:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
class ActiveRecordWidgetBase < ActiveRecord::Base
|
|
|
|
def self.establish_connection_one
|
|
|
|
establish_connection(:adapter => "#{"jdbc" if defined?(JRUBY_VERSION)}sqlite3", :database => "#{DB_DIR}/activerecord_one.db")
|
|
|
|
end
|
2010-05-18 06:50:20 +00:00
|
|
|
|
2010-05-25 17:21:45 +00:00
|
|
|
def self.establish_connection_two
|
|
|
|
establish_connection(:adapter => "#{"jdbc" if defined?(JRUBY_VERSION)}sqlite3", :database => "#{DB_DIR}/activerecord_two.db")
|
|
|
|
end
|
2009-03-04 04:53:21 +00:00
|
|
|
end
|
|
|
|
|
2010-05-16 21:26:09 +00:00
|
|
|
unless defined? Widget
|
2010-05-25 17:21:45 +00:00
|
|
|
class Widget < ActiveRecordWidgetBase
|
|
|
|
set_table_name 'widgets'
|
2010-05-16 21:26:09 +00:00
|
|
|
end
|
|
|
|
else
|
2010-05-25 17:21:45 +00:00
|
|
|
class AnotherWidget < ActiveRecordWidgetBase
|
|
|
|
set_table_name 'another_widgets'
|
|
|
|
end
|
2009-03-04 04:53:21 +00:00
|
|
|
end
|