mysql_rewinder 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/mysql_rewinder/cleaner.rb +6 -2
- data/lib/mysql_rewinder/version.rb +1 -1
- data/lib/mysql_rewinder.rb +4 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b26b4b3f9253154ce344e453cea49761de30336c9998ce7bd65866172db1f24a
|
4
|
+
data.tar.gz: 1c603d2142d178abc6d6a0a6b140e333ff18acdb7749dbd3272a43af5c49ee16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90f486dabb787181ec7ad00898b0c2240779b353c38cb6f23e9eba7a138ea52ea80ba50f195ff0bed109d4d1d4f4e1022ab5b995aebd67c552a36f1c06edc0bf
|
7
|
+
data.tar.gz: 6b3acac13d28c0696b21c729df206a8c141b82e0eff12a675f51e8f2272b43a325278817f1584c4e140324557c05b84cc5c05abd34b1cf9a79f5f45e4131f0ab
|
data/Gemfile.lock
CHANGED
@@ -19,7 +19,11 @@ class MysqlRewinder
|
|
19
19
|
|
20
20
|
def clean(tables:)
|
21
21
|
target_tables = (tables - @except_tables) & all_tables
|
22
|
-
|
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 @@ class MysqlRewinder
|
|
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
|
data/lib/mysql_rewinder.rb
CHANGED
@@ -56,7 +56,10 @@ class MysqlRewinder
|
|
56
56
|
end
|
57
57
|
|
58
58
|
@inserted_tables = Set.new
|
59
|
-
|
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
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mysql_rewinder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yusuke Sangenya
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|