Sha256: 55ad6408dc00f6726b2ea1d35878e39158bec3e40d2c497c535ae6577a86183f

Contents?: true

Size: 1.54 KB

Versions: 66

Compression:

Stored size: 1.54 KB

Contents

require 'active_record'
databases_config = {
  "one" => {"adapter" => "#{"jdbc" if defined?(JRUBY_VERSION)}sqlite3", "database" => "#{DB_DIR}/activerecord_one.db"},
  "two" => {"adapter" => "#{"jdbc" if defined?(JRUBY_VERSION)}sqlite3", "database" => "#{DB_DIR}/activerecord_two.db"}
}

File.open("#{File.dirname(__FILE__)}/../config/database.yml", 'w') do |file|
  file.write(YAML.dump(databases_config))
end

["two","one"].each do |db|
  ActiveRecord::Base.establish_connection(databases_config[db])
  ActiveRecord::Base.connection.execute('DROP TABLE IF EXISTS "active_record_widgets"')
  ActiveRecord::Base.connection.execute('DROP TABLE IF EXISTS "active_record_widget_using_database_ones"')
  ActiveRecord::Base.connection.execute('DROP TABLE IF EXISTS "active_record_widget_using_database_twos"')

  ActiveRecord::Schema.define(:version => 1) do
    create_table :active_record_widgets do |t|
      t.string :name
    end

    create_table :active_record_widget_using_database_ones do |t|
      t.string :name
    end

    create_table :active_record_widget_using_database_twos do |t|
      t.string :name
    end
  end
end

class ActiveRecordWidget < ActiveRecord::Base
end

class ActiveRecordWidgetUsingDatabaseOne < ActiveRecord::Base
  establish_connection(:adapter => "#{"jdbc" if defined?(JRUBY_VERSION)}sqlite3", :database => "#{DB_DIR}/activerecord_one.db")
end

class ActiveRecordWidgetUsingDatabaseTwo < ActiveRecord::Base
  establish_connection(:adapter => "#{"jdbc" if defined?(JRUBY_VERSION)}sqlite3", :database => "#{DB_DIR}/activerecord_two.db")
end

Version data entries

66 entries across 55 versions & 8 rubygems

Version Path
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/database_cleaner-0.7.2/examples/lib/activerecord_models.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/database_cleaner-0.7.2/examples/lib/activerecord_models.rb
rails-uploader-0.0.4 vendor/bundle/ruby/1.9.1/gems/database_cleaner-0.8.0/examples/lib/activerecord_models.rb
rails-uploader-0.0.4 vendor/bundle/ruby/1.9.1/gems/database_cleaner-0.7.2/examples/lib/activerecord_models.rb
database_cleaner-0.8.0 examples/lib/activerecord_models.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/database_cleaner-0.7.2/examples/lib/activerecord_models.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/database_cleaner-0.7.2/examples/lib/activerecord_models.rb
rails-uploader-0.0.1 vendor/bundle/ruby/1.9.1/gems/database_cleaner-0.7.2/examples/lib/activerecord_models.rb
database_cleaner-0.7.2 examples/lib/activerecord_models.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/database_cleaner-0.6.7/examples/lib/activerecord_models.rb
database_cleaner-0.7.1 examples/lib/activerecord_models.rb
database_cleaner-0.7.0 examples/lib/activerecord_models.rb
database_cleaner-0.6.7 examples/lib/activerecord_models.rb
database_cleaner-0.6.7.RC examples/lib/activerecord_models.rb
database_cleaner-0.6.6 examples/lib/activerecord_models.rb
database_cleaner-0.6.5 examples/lib/activerecord_models.rb
database_cleaner-0.6.4 examples/lib/activerecord_models.rb
database_cleaner-0.6.3 examples/lib/activerecord_models.rb
database_cleaner-0.6.2 examples/lib/activerecord_models.rb
database_cleaner-0.6.1 examples/lib/activerecord_models.rb