68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/synchronised_migration/commands.rb', line 68
def call(**options)
abort "Config location must be provided" if options[:config].nil?
abort "Version must be provided" if options[:version].nil?
config = SynchronisedMigration::Configuration.from_cli(options)
redis_opts = {url: config.redis_uri}
redis_opts[:logger] = Logger.new($stdout) if config.debug?
redis = Redis.new(redis_opts)
rows = []
fail_key = config.fail_key
rows << if redis.exists?(fail_key)
[fail_key, "true", "Failed Migration"]
else
[fail_key, "false", nil]
end
success_key = config.success_key
rows << if redis.exists?(success_key)
[success_key, "true", "successfully Migrated"]
else
[success_key, "false", nil]
end
lock_key = config.lock_key
rows << if redis.exists?(lock_key)
[lock_key, "true", "Running Migration"]
else
[lock_key, "false", nil]
end
table = TTY::Table.new(["key", "status", "message"], rows)
$stdout.puts table.render(:ascii)
end
|