Sha256: 445a4bf3961b5230cbfbd24dc4168db3be4054526e02fe4be6475ce38d8f3f1f
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
require 'rubygems' require 'bundler/setup' ENV['RACK_ENV'] = 'test' require 'standby' ActiveRecord::Base.configurations = { 'test' => { 'adapter' => 'sqlite3', 'database' => 'spec/db/test_db' }, 'test_standby' => { 'adapter' => 'sqlite3', 'database' => 'spec/db/test_standby_one' }, 'test_standby_two' => { 'adapter' => 'sqlite3', 'database' => 'spec/db/test_standby_two'}, 'test_standby_url' => 'postgres://root:@localhost:5432/test_standby' } # Prepare databases class User < ActiveRecord::Base has_many :items attr_accessor :name end class Item < ActiveRecord::Base belongs_to :user, inverse_of: :items end class Seeder def run # Populate on primary connect(:test) create_tables User.create User.create User.first.items.create # Populate on standby, emulating replication lag connect(:test_standby) create_tables User.create # Populate on standby two connect(:test_standby_two) create_tables # Reconnect to primary connect(:test) end def create_tables ActiveRecord::Base.connection.create_table :users, force: true ActiveRecord::Base.connection.create_table :items, force: true do |t| t.references :user end end def connect(env) ActiveRecord::Base.establish_connection(env) end end Seeder.new.run
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
standby-5.0.0 | spec/spec_helper.rb |