Skip to content

Commit

Permalink
prefixed warnings with redis-objects
Browse files Browse the repository at this point in the history
  • Loading branch information
nateware committed Mar 30, 2023
1 parent 84bff78 commit 8ab0b42
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/redis/objects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ def redis_legacy_naming_warning_message(klass)
legacy = redis_legacy_prefix(klass)
if modern != legacy
warn <<EOW
WARNING: In redis-objects 2.0.0, key naming will change to fix longstanding bugs.
Your class #{klass.name.to_s} will be affected by this change!
Current key prefix: #{legacy.inspect}
Future key prefix: #{modern.inspect}
Read more at https://github.com/nateware/redis-objects/issues/231
[redis-objects] WARNING: In redis-objects 2.0.0, key naming will change to fix longstanding bugs.
[redis-objects] Your class #{klass.name.to_s} will be affected by this change!
[redis-objects] Current key prefix: #{legacy.inspect}
[redis-objects] Future key prefix: #{modern.inspect}
[redis-objects] Read more at https://github.com/nateware/redis-objects/issues/231
EOW
end
end
Expand All @@ -165,7 +165,7 @@ def migrate_redis_legacy_keys
if legacy == redis_prefix
raise "Failed to migrate keys for #{self.name.to_s} as legacy and new redis_prefix are the same (#{redis_prefix})"
end
warn "Migrating keys from #{legacy} prefix to #{redis_prefix}"
warn "[redis-objects] Migrating keys from #{legacy} prefix to #{redis_prefix}"

loop do
cursor, keys = redis.scan(cursor, :match => "#{legacy}:*")
Expand All @@ -178,14 +178,14 @@ def migrate_redis_legacy_keys
new_key = redis_field_key(name, id=id, context=self)

# Rename the key
warn "Rename '#{key}', '#{new_key}'"
warn "[redis-objects] Rename '#{key}', '#{new_key}'"
ok = redis.rename(key, new_key)
warn "Warning: Rename '#{key}', '#{new_key}' failed: #{ok}" if ok != 'OK'
warn "[redis-objects] Warning: Rename '#{key}', '#{new_key}' failed: #{ok}" if ok != 'OK'
end
break if cursor == "0"
end

warn "Migrated #{total_keys} total number of redis keys"
warn "[redis-objects] Migrated #{total_keys} total number of redis keys"
end

def redis_options(name)
Expand Down

0 comments on commit 8ab0b42

Please sign in to comment.