18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/convergence/command/apply.rb', line 18
def execute_sql(input_tables, current_tables)
sql = generate_sql(input_tables, current_tables)
unless sql.strip.empty?
sql = <<-SQL
SET FOREIGN_KEY_CHECKS=0;
#{sql}
SET FOREIGN_KEY_CHECKS=1;
SQL
end
sql.split(';').each do |q2|
q = q2.strip
unless q.empty?
begin
q = q + ';'
time = Benchmark.realtime { connector.client.query(q) }
logger.output q
logger.output " --> #{time}s"
rescue => e
logger.output 'Invalid Query Exception >>>'
logger.output q
logger.output '<<<'
throw e
end
end
end
end
|