Module: Switchman::ActiveRecord::Migrator
- Defined in:
- lib/switchman/active_record/migration.rb
Instance Method Summary collapse
-
#generate_migrator_advisory_lock_id ⇒ Object
significant change: use the shard name instead of the database name in the lock id.
- #use_advisory_lock? ⇒ Boolean
Instance Method Details
#generate_migrator_advisory_lock_id ⇒ Object
significant change: use the shard name instead of the database name in the lock id. Especially if you’re going through pgbouncer, the database name you’re accessing may not be consistent
28 29 30 31 32 33 34 |
# File 'lib/switchman/active_record/migration.rb', line 28 def generate_migrator_advisory_lock_id db_name_hash = Zlib.crc32(Shard.current.name) shard_name_hash = ::ActiveRecord::Migrator::MIGRATOR_SALT * db_name_hash # Store in internalmetadata to allow other tools to be able to lock out migrations @internal_metadata[:migrator_advisory_lock_id] = shard_name_hash.to_s shard_name_hash end |
#use_advisory_lock? ⇒ Boolean
36 37 38 |
# File 'lib/switchman/active_record/migration.rb', line 36 def use_advisory_lock? super && pending_migrations.any? end |