Module: SimpleDataMigrations::ConcurrentRun
- Defined in:
- lib/simple_data_migrations/concurrent_run.rb
Defined Under Namespace
Classes: Error
Class Method Summary collapse
Class Method Details
.with_advisory_lock ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/simple_data_migrations/concurrent_run.rb', line 10 def self.with_advisory_lock with_advisory_lock_connection do |connection| lock_id = MIGRATOR_SALT * Zlib.crc32(connection.current_database) got_lock = connection.get_advisory_lock(lock_id) raise Error unless got_lock yield ensure got_lock && connection.release_advisory_lock(lock_id) end end |