method

with_advisory_lock

rails latest stable - Class: ActiveRecord::InvalidMigrationTimestampError::Migrator

Method not available on this version

This method is only available on newer versions. The first available version (v7.2.3) is shown here.

with_advisory_lock()
private

No documentation available.

# File activerecord/lib/active_record/migration.rb, line 1604
      def with_advisory_lock
        lock_id = generate_migrator_advisory_lock_id

        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