Skip to content

Commit cd5675f

Browse files
committed
avoid always updating migration advisory lock
it's stored as a string, not an integer also avoid extra instantiations of InternalMetadata when we already have it available Change-Id: Ib58953c90e6f22dfa81f2d6beaf6b8d0c7040026 Reviewed-on: https://gerrit.instructure.com/c/switchman/+/379550 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Aaron Ogata <aogata@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com>
1 parent 06cd888 commit cd5675f

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/switchman/active_record/migration.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ def generate_migrator_advisory_lock_id
3030
shard_name_hash = ::ActiveRecord::Migrator::MIGRATOR_SALT * db_name_hash
3131
# Store in internalmetadata to allow other tools to be able to lock out migrations
3232
if ::Rails.version < "7.1"
33-
::ActiveRecord::InternalMetadata[:migrator_advisory_lock_id] = shard_name_hash
34-
elsif ::Rails.version < "7.2"
35-
::ActiveRecord::InternalMetadata.new(connection)[:migrator_advisory_lock_id] = shard_name_hash
33+
::ActiveRecord::InternalMetadata[:migrator_advisory_lock_id] = shard_name_hash.to_s
3634
else
37-
::ActiveRecord::InternalMetadata.new(connection.pool)[:migrator_advisory_lock_id] = shard_name_hash
35+
@internal_metadata[:migrator_advisory_lock_id] = shard_name_hash.to_s
3836
end
3937
shard_name_hash
4038
end

0 commit comments

Comments
 (0)