litestream 0.7.2-x86_64-darwin → 0.8.0-x86_64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/litestream/commands.rb +19 -6
- data/lib/litestream/version.rb +1 -1
- data/lib/tasks/litestream_tasks.rake +13 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d7e03df8e744e723a6388ee5fb5aec57681a54744ef20773914d3cf60d2981b
|
4
|
+
data.tar.gz: a4357bd0602b15de95234af65b134b0509dd6303af905437e6ea2be5a253aa53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 887ab6796e6fd71a3fc956455d31f39577e4766f66bdc2f269ee6868154544404e21fa934d15711580f4048441d1c3293ad94572975f1103c8fbaa8774330f82
|
7
|
+
data.tar.gz: 3db7e04c5fa322d6659de1da6663b48dc339d3a48c13f8c92f33f919156a4c842452a7191a735a545e8abed58050e028c40490bdc767358e9af471183b456d96
|
data/lib/litestream/commands.rb
CHANGED
@@ -102,16 +102,29 @@ module Litestream
|
|
102
102
|
}.merge(argv)
|
103
103
|
restore(database, async: false, **args)
|
104
104
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
105
|
+
restored_schema = `sqlite3 #{backup} "select name, type from sqlite_schema;"`.chomp.split("\n")
|
106
|
+
restored_data = restored_schema.map { _1.split("|") }.group_by(&:last)
|
107
|
+
restored_rows_count = restored_data["table"]&.sum { |tbl, _| `sqlite3 #{backup} "select count(*) from #{tbl};"`.chomp.to_i }
|
108
|
+
|
109
|
+
original_schema = `sqlite3 #{database} "select name, type from sqlite_schema;"`.chomp.split("\n")
|
110
|
+
original_data = original_schema.map { _1.split("|") }.group_by(&:last)
|
111
|
+
original_rows_count = original_data["table"]&.sum { |tbl, _| `sqlite3 #{database} "select count(*) from #{tbl};"`.chomp.to_i }
|
109
112
|
|
110
113
|
Dir.glob(backup + "*").each { |file| File.delete(file) }
|
111
114
|
|
112
115
|
{
|
113
|
-
"
|
114
|
-
|
116
|
+
"original" => {
|
117
|
+
"path" => database,
|
118
|
+
"tables" => original_data["table"]&.size,
|
119
|
+
"indexes" => original_data["index"]&.size,
|
120
|
+
"rows" => original_rows_count
|
121
|
+
},
|
122
|
+
"restored" => {
|
123
|
+
"path" => backup,
|
124
|
+
"tables" => restored_data["table"]&.size,
|
125
|
+
"indexes" => restored_data["index"]&.size,
|
126
|
+
"rows" => restored_rows_count
|
127
|
+
}
|
115
128
|
}
|
116
129
|
end
|
117
130
|
|
data/lib/litestream/version.rb
CHANGED
@@ -96,15 +96,20 @@ namespace :litestream do
|
|
96
96
|
|
97
97
|
puts <<~TXT if result
|
98
98
|
|
99
|
-
size
|
100
|
-
original #{result["size"]["original"]}
|
101
|
-
restored #{result["size"]["restored"]}
|
102
|
-
delta #{result["size"]["original"] - result["size"]["restored"]}
|
103
|
-
|
104
99
|
tables
|
105
|
-
original #{result["
|
106
|
-
restored #{result["
|
107
|
-
delta #{result["
|
100
|
+
original #{result["original"]["tables"]}
|
101
|
+
restored #{result["restored"]["tables"]}
|
102
|
+
delta #{result["original"]["tables"] - result["restored"]["tables"]}
|
103
|
+
|
104
|
+
indexes
|
105
|
+
original #{result["original"]["indexes"]}
|
106
|
+
restored #{result["restored"]["indexes"]}
|
107
|
+
delta #{result["original"]["indexes"] - result["restored"]["indexes"]}
|
108
|
+
|
109
|
+
rows
|
110
|
+
original #{result["original"]["rows"]}
|
111
|
+
restored #{result["restored"]["rows"]}
|
112
|
+
delta #{result["original"]["rows"] - result["restored"]["rows"]}
|
108
113
|
TXT
|
109
114
|
end
|
110
115
|
end
|