37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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
103
104
105
106
107
108
109
110
111
|
# File 'lib/tableflip/argument_parser.rb', line 37
def parser(strategy)
OptionParser.new do |parser|
parser.banner = "Usage: tableflip [options] [table_name [table_name [...]]]"
parser.separator("")
parser.separator("Options:")
parser.on("-a", "--all", "Track all tables") do |s|
strategy.tables << :__all__
end
parser.on("-i", "--insert", "Use INSERT IGNORE instead of REPLACE INTO") do
strategy.migrate_method = :insert
end
parser.on("-b", "--block=s", "Transfer data in blocks of N rows") do |s|
strategy.block_size = s.to_i
end
parser.on("-f", "--config=s") do |path|
strategy.config_path = path
end
parser.on("-t", "--track", "Add tracking triggers on tables") do
strategy.actions << :tracking_add
end
parser.on("-d", "--seed", "Seed the tracking table with entries from the source table") do
strategy.actions << :tracking_seed
end
parser.on("-r", "--remove", "Remove tracking triggers from tables") do
strategy.actions << :tracking_remove
end
parser.on("-o", "--target=s", "Set target environment") do |s|
strategy.target_env = s
end
parser.on("-m", "--migrate", "Migrate data from source to target") do
strategy.actions << :table_migrate
end
parser.on("-c", "--count", "Count number of records in source table") do
strategy.actions << :table_count
end
parser.on("-s", "--status", "Show current status") do
strategy.actions << :table_report_status
end
parser.on("-e", "--env=s", "Establish primary environment") do |s|
strategy.source_env = s
end
parser.on("-x", "--exclude=s", "Exclude column(s) from migration") do |s|
s.split(/,/).each do |column|
strategy.exclude_columns << column
end
end
parser.on("-n", "--encoding=s", "Set connection encoding") do |s|
strategy.encoding = s
end
parser.on("-k", "--create-test", "Creates a test table") do
strategy.actions << :table_create_test
end
parser.on("-z", "--fuzz[=d]", "Inserts and alters records on test table") do |d|
strategy.actions << :table_fuzz
if (d)
strategy.fuzz_intensity = d.to_i
end
end
parser.on("-p", "--persist", "Keep running perpetually") do
strategy.persist = true
end
parser.on("-w","--where=s", "Add conditions to selecting") do |s|
strategy.where = s
end
parser.on("-q", "--debug", "Show the queries as they're executed") do
strategy.debug_queries = true
end
parser.on("-h", "--help", "Display this help") do
strategy.message = parser.to_s
end
end
end
|