Module: Switchman::ActiveRecord::Migrator
- Defined in:
- lib/switchman/active_record/migration.rb
Instance Method Summary collapse
-
#generate_migrator_advisory_lock_id ⇒ Object
significant change: just return MIGRATOR_SALT directly especially if you’re going through pgbouncer, the database name you’re accessing may not be consistent.
-
#with_advisory_lock_connection ⇒ Object
significant change: strip out prefer_secondary from config.
Instance Method Details
#generate_migrator_advisory_lock_id ⇒ Object
significant change: just return MIGRATOR_SALT directly especially if you’re going through pgbouncer, the database name you’re accessing may not be consistent. it is NOT allowed to run migrations against multiple shards in the same database concurrently
28 29 30 |
# File 'lib/switchman/active_record/migration.rb', line 28 def generate_migrator_advisory_lock_id ::ActiveRecord::Migrator::MIGRATOR_SALT end |
#with_advisory_lock_connection ⇒ Object
significant change: strip out prefer_secondary from config
33 34 35 36 37 38 39 40 41 |
# File 'lib/switchman/active_record/migration.rb', line 33 def with_advisory_lock_connection pool = ::ActiveRecord::ConnectionAdapters::ConnectionHandler.new.establish_connection( ::ActiveRecord::Base.connection_db_config.configuration_hash.except(:prefer_secondary) ) pool.with_connection { |connection| yield(connection) } # rubocop:disable Style/ExplicitBlockArgument ensure pool&.disconnect! end |