14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/redcord/migration/migrator.rb', line 14
def self.migrate(redis:, version:, direction:)
migration = load_version(version)
print [
T.must("#{redis.inspect.match('(redis://.*)>')[1]}"[0...30]),
direction.to_s.upcase,
version,
T.must(migration.name).underscore.humanize,
].map { |str| str.ljust(30) }.join("\t")
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
migration.new(redis).send(direction)
if direction == :up
redis.sadd(
Redcord::Migration::Version::MIGRATION_VERSIONS_REDIS_KEY,
version,
)
else
redis.srem(
Redcord::Migration::Version::MIGRATION_VERSIONS_REDIS_KEY,
version,
)
end
end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
puts "\t#{(end_time - start_time) * 1000.0.round(3)} ms"
end
|