File tree 2 files changed +10
-3
lines changed
2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,10 @@ def reset_inserted_tables
56
56
end
57
57
58
58
@inserted_tables = Set . new
59
- FileUtils . rm ( Dir . glob ( @inserted_table_record_dir . join ( "#{ @initialized_pid } .*.inserted_tables" ) . to_s ) )
59
+ files = Dir . glob ( @inserted_table_record_dir . join ( "#{ @initialized_pid } .*.inserted_tables" ) . to_s )
60
+
61
+ FileUtils . rm ( files )
62
+ @logger &.debug { "[MysqlRewinder] removed files: #{ files . join ( ', ' ) } " } if files . any?
60
63
end
61
64
62
65
def calculate_inserted_tables
Original file line number Diff line number Diff line change @@ -19,7 +19,11 @@ def clean_all
19
19
20
20
def clean ( tables :)
21
21
target_tables = ( tables - @except_tables ) & all_tables
22
- return if target_tables . empty?
22
+
23
+ if target_tables . empty?
24
+ @logger &.debug { "[MysqlRewinder][#{ @db_config [ :database ] } ] Skip DELETE query because target_table is empty." }
25
+ return
26
+ end
23
27
24
28
log_and_execute ( "SET FOREIGN_KEY_CHECKS = 0;" )
25
29
log_and_execute ( target_tables . map { |table | "DELETE FROM #{ table } " } . join ( ';' ) )
@@ -42,7 +46,7 @@ def log_and_execute(sql)
42
46
res = @client . execute ( sql )
43
47
duration = ( Time . now - start_ts ) * 1000
44
48
45
- name = "[MysqlRewinder] Cleaner SQL (#{ duration . round ( 1 ) } ms)"
49
+ name = "[MysqlRewinder][ #{ @db_config [ :database ] } ] Cleaner SQL (#{ duration . round ( 1 ) } ms)"
46
50
msg = "\e [1m\e [30m#{ name } \e [0m \e [34m#{ sql } \e [0m"
47
51
@logger . debug msg
48
52
res
You can’t perform that action at this time.
0 commit comments