Flowdock
method

with_advisory_lock

Importance_0
v5.2.3 - Show latest stable - 0 notes - Class: ActiveRecord::Migrator
with_advisory_lock() private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/migration.rb, line 1357
      def with_advisory_lock
        lock_id = generate_migrator_advisory_lock_id
        connection = Base.connection
        got_lock = connection.get_advisory_lock(lock_id)
        raise ConcurrentMigrationError unless got_lock
        load_migrated # reload schema_migrations to be sure it wasn't changed by another process before we got the lock
        yield
      ensure
        if got_lock && !connection.release_advisory_lock(lock_id)
          raise ConcurrentMigrationError.new(
            ConcurrentMigrationError::RELEASE_LOCK_FAILED_MESSAGE
          )
        end
      end
Register or log in to add new notes.