tapsoob 0.4.21-java → 0.4.27-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tapsoob/cli/data_stream.rb +1 -11
- data/lib/tapsoob/cli/root.rb +4 -11
- data/lib/tapsoob/operation.rb +15 -12
- data/lib/tapsoob/version.rb +1 -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: c84cbc1fe369db1a683ba05335edcb1fc8d2f5960df108830cf0955279c1d10e
|
4
|
+
data.tar.gz: c69c9fbdd7f5eea1ec8ed856384c6632857a618539cbe76244116961d1ad89eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5eef5462b169ca16e4bc8a26c7fcd8e29f29c17e34c6f3b3d606a3a6049d4ede824018774645ca62de3642cedc760dc32095fd9a0837f9077c097887badfd1d
|
7
|
+
data.tar.gz: 05a13f40619677e5a4eef21e357e1e056cc76bdaf72e22fa5bc1cd06577c6afca0b6a7f7343589967dbd185a0b06263bbc031ae77cb55b3382d37dd9f8f93d4f
|
@@ -12,7 +12,6 @@ module Tapsoob
|
|
12
12
|
class DataStream < Thor
|
13
13
|
desc "pull DATABASE_URL [DUMP_PATH]", "Pull data from a database."
|
14
14
|
option :chunksize, desc: "Initial chunksize", default: 1000, type: :numeric, aliases: "-c"
|
15
|
-
option :filter, desc: "Regex Filter for tables", type: :string, aliases: "-f"
|
16
15
|
option :tables, desc: "Shortcut to filter on a list of tables", type: :array, aliases: "-t"
|
17
16
|
option :"exclude-tables", desc: "Shortcut to exclude a list of tables", type: :array, aliases: "-e"
|
18
17
|
option :progress, desc: "Show progress", default: true, type: :boolean, aliases: "-p"
|
@@ -24,7 +23,6 @@ module Tapsoob
|
|
24
23
|
|
25
24
|
desc "push DATABASE_URL [DUMP_PATH]", "Push data to a database."
|
26
25
|
option :chunksize, desc: "Initial chunksize", default: 1000, type: :numeric, aliases: "-c"
|
27
|
-
option :filter, desc: "Regex Filter for tables", type: :string, aliases: "-f"
|
28
26
|
option :tables, desc: "Shortcut to filter on a list of tables", type: :array, aliases: "-t"
|
29
27
|
option :"exclude-tables", desc: "Shortcut to exclude a list of tables", type: :array, aliases: "-e"
|
30
28
|
option :progress, desc: "Show progress", default: true, type: :boolean, aliases: "-p"
|
@@ -65,6 +63,7 @@ module Tapsoob
|
|
65
63
|
# Default options
|
66
64
|
opts = {
|
67
65
|
progress: options[:progress],
|
66
|
+
tables: options[:tables],
|
68
67
|
debug: options[:debug]
|
69
68
|
}
|
70
69
|
|
@@ -78,15 +77,6 @@ module Tapsoob
|
|
78
77
|
opts[:default_chunksize] = (options[:chunksize] < 10 ? 10 : options[:chunksize])
|
79
78
|
end
|
80
79
|
|
81
|
-
# Regex filter
|
82
|
-
opts[:table_filter] = options[:filter] if options[:filter]
|
83
|
-
|
84
|
-
# Table filter
|
85
|
-
if options[:tables]
|
86
|
-
r_tables = options[:tables].collect { |t| "^#{t}" }.join("|")
|
87
|
-
opts[:table_filter] = "#{r_tables}"
|
88
|
-
end
|
89
|
-
|
90
80
|
# Exclude tables
|
91
81
|
opts[:exclude_tables] = options[:"exclude-tables"] if options[:"exclude-tables"]
|
92
82
|
|
data/lib/tapsoob/cli/root.rb
CHANGED
@@ -10,12 +10,12 @@ module Tapsoob
|
|
10
10
|
module CLI
|
11
11
|
class Root < Thor
|
12
12
|
desc "pull DUMP_PATH DATABASE_URL", "Pull a dump from a database to a folder"
|
13
|
+
option :"schema-only", desc: "Don't transfer the data just schema", default: false, type: :boolean
|
13
14
|
option :"skip-schema", desc: "Don't transfer the schema just data", default: false, type: :boolean, aliases: "-s"
|
14
15
|
option :"indexes-first", desc: "Transfer indexes first before data", default: false, type: :boolean, aliases: "-i"
|
15
16
|
option :resume, desc: "Resume a Tapsoob Session from a stored file", type: :string, aliases: "-r"
|
16
17
|
option :chunksize, desc: "Initial chunksize", default: 1000, type: :numeric, aliases: "-c"
|
17
18
|
option :"disable-compression", desc: "Disable Compression", default: false, type: :boolean, aliases: "-g"
|
18
|
-
option :filter, desc: "Regex Filter for tables", type: :string, aliases: "-f"
|
19
19
|
option :tables, desc: "Shortcut to filter on a list of tables", type: :array, aliases: "-t"
|
20
20
|
option :"exclude-tables", desc: "Shortcut to exclude a list of tables", type: :array, aliases: "-e"
|
21
21
|
option :debug, desc: "Enable debug messages", default: false, type: :boolean, aliases: "-d"
|
@@ -30,12 +30,12 @@ module Tapsoob
|
|
30
30
|
end
|
31
31
|
|
32
32
|
desc "push DUMP_PATH DATABASE_URL", "Push a previously tapsoob dump to a database"
|
33
|
+
option :"schema-only", desc: "Don't transfer the data just schema", default: false, type: :boolean
|
33
34
|
option :"skip-schema", desc: "Don't transfer the schema just data", default: false, type: :boolean, aliases: "-s"
|
34
35
|
option :"indexes-first", desc: "Transfer indexes first before data", default: false, type: :boolean, aliases: "-i"
|
35
36
|
option :resume, desc: "Resume a Tapsoob Session from a stored file", type: :string, aliases: "-r"
|
36
37
|
option :chunksize, desc: "Initial chunksize", default: 1000, type: :numeric, aliases: "-c"
|
37
38
|
option :"disable-compression", desc: "Disable Compression", default: false, type: :boolean, aliases: "-g"
|
38
|
-
option :filter, desc: "Regex Filter for tables", type: :string, aliases: "-f"
|
39
39
|
option :tables, desc: "Shortcut to filter on a list of tables", type: :array, aliases: "-t"
|
40
40
|
option :"exclude-tables", desc: "Shortcut to exclude a list of tables", type: :array, aliases: "-e"
|
41
41
|
option :purge, desc: "Purge data in tables prior to performing the import", default: false, type: :boolean, aliases: "-p"
|
@@ -67,9 +67,11 @@ module Tapsoob
|
|
67
67
|
def parse_opts(options)
|
68
68
|
# Default options
|
69
69
|
opts = {
|
70
|
+
schema_only: options[:"schema-only"],
|
70
71
|
skip_schema: options[:"skip-schema"],
|
71
72
|
indexes_first: options[:"indexes_first"],
|
72
73
|
disable_compression: options[:"disable-compression"],
|
74
|
+
tables: options[:tables],
|
73
75
|
debug: options[:debug]
|
74
76
|
}
|
75
77
|
|
@@ -92,15 +94,6 @@ module Tapsoob
|
|
92
94
|
opts[:default_chunksize] = (options[:chunksize] < 10 ? 10 : options[:chunksize])
|
93
95
|
end
|
94
96
|
|
95
|
-
# Regex filter
|
96
|
-
opts[:table_filter] = options[:filter] if options[:filter]
|
97
|
-
|
98
|
-
# Table filter
|
99
|
-
if options[:tables]
|
100
|
-
r_tables = options[:tables].collect { |t| "^#{t}" }.join("|")
|
101
|
-
opts[:table_filter] = "#{r_tables}"
|
102
|
-
end
|
103
|
-
|
104
97
|
# Exclude tables
|
105
98
|
opts[:exclude_tables] = options[:"exclude-tables"] if options[:"exclude-tables"]
|
106
99
|
|
data/lib/tapsoob/operation.rb
CHANGED
@@ -21,6 +21,10 @@ module Tapsoob
|
|
21
21
|
"op"
|
22
22
|
end
|
23
23
|
|
24
|
+
def schema_only?
|
25
|
+
!!opts[:schema_only]
|
26
|
+
end
|
27
|
+
|
24
28
|
def skip_schema?
|
25
29
|
!!opts[:skip_schema]
|
26
30
|
end
|
@@ -30,7 +34,7 @@ module Tapsoob
|
|
30
34
|
end
|
31
35
|
|
32
36
|
def table_filter
|
33
|
-
opts[:
|
37
|
+
opts[:tables] || []
|
34
38
|
end
|
35
39
|
|
36
40
|
def exclude_tables
|
@@ -38,19 +42,18 @@ module Tapsoob
|
|
38
42
|
end
|
39
43
|
|
40
44
|
def apply_table_filter(tables)
|
41
|
-
return tables
|
45
|
+
return tables if table_filter.empty? && exclude_tables.empty?
|
42
46
|
|
43
|
-
re = table_filter ? Regexp.new(table_filter) : nil
|
44
47
|
if tables.kind_of?(Hash)
|
45
48
|
ntables = {}
|
46
49
|
tables.each do |t, d|
|
47
|
-
if !exclude_tables.include?(t.to_s) && (!
|
50
|
+
if !exclude_tables.include?(t.to_s) && (!table_filter.empty? && table_filter.include?(t.to_s))
|
48
51
|
ntables[t] = d
|
49
52
|
end
|
50
53
|
end
|
51
54
|
ntables
|
52
55
|
else
|
53
|
-
tables.reject { |t| exclude_tables.include?(t.to_s)
|
56
|
+
tables.reject { |t| exclude_tables.include?(t.to_s) }.select { |t| table_filter.include?(t.to_s) }
|
54
57
|
end
|
55
58
|
end
|
56
59
|
|
@@ -168,7 +171,7 @@ module Tapsoob
|
|
168
171
|
end
|
169
172
|
setup_signal_trap
|
170
173
|
pull_partial_data if resuming?
|
171
|
-
pull_data
|
174
|
+
pull_data unless schema_only?
|
172
175
|
pull_indexes if !indexes_first? && !skip_schema?
|
173
176
|
pull_reset_sequences
|
174
177
|
end
|
@@ -182,7 +185,7 @@ module Tapsoob
|
|
182
185
|
schema_data = Tapsoob::Schema.dump_table(database_url, table_name)
|
183
186
|
log.debug "Table: #{table_name}\n#{schema_data}\n"
|
184
187
|
output = Tapsoob::Utils.export_schema(dump_path, table_name, schema_data)
|
185
|
-
puts output if output
|
188
|
+
puts output if dump_path.nil? && output
|
186
189
|
progress.inc(1)
|
187
190
|
end
|
188
191
|
progress.finish
|
@@ -290,7 +293,7 @@ module Tapsoob
|
|
290
293
|
def pull_indexes
|
291
294
|
log.info "Receiving indexes"
|
292
295
|
|
293
|
-
raw_idxs = Tapsoob::
|
296
|
+
raw_idxs = Tapsoob::Schema.indexes_individual(database_url)
|
294
297
|
idxs = (raw_idxs && raw_idxs.length >= 2 ? JSON.parse(raw_idxs) : {})
|
295
298
|
|
296
299
|
apply_table_filter(idxs).each do |table, indexes|
|
@@ -298,7 +301,7 @@ module Tapsoob
|
|
298
301
|
progress = ProgressBar.new(table, indexes.size)
|
299
302
|
indexes.each do |idx|
|
300
303
|
output = Tapsoob::Utils.export_indexes(dump_path, table, idx)
|
301
|
-
puts output if output
|
304
|
+
puts output if dump_path.nil? && output
|
302
305
|
progress.inc(1)
|
303
306
|
end
|
304
307
|
progress.finish
|
@@ -309,7 +312,7 @@ module Tapsoob
|
|
309
312
|
log.info "Resetting sequences"
|
310
313
|
|
311
314
|
output = Tapsoob::Utils.schema_bin(:reset_db_sequences, database_url)
|
312
|
-
puts output if output
|
315
|
+
puts output if dump_path.nil? && output
|
313
316
|
end
|
314
317
|
end
|
315
318
|
|
@@ -330,7 +333,7 @@ module Tapsoob
|
|
330
333
|
end
|
331
334
|
setup_signal_trap
|
332
335
|
push_partial_data if resuming?
|
333
|
-
push_data
|
336
|
+
push_data unless schema_only?
|
334
337
|
push_indexes if !indexes_first? && !skip_schema?
|
335
338
|
push_reset_sequences
|
336
339
|
end
|
@@ -393,7 +396,7 @@ module Tapsoob
|
|
393
396
|
log.info "#{tables.size} tables, #{format_number(record_count)} records"
|
394
397
|
|
395
398
|
tables.each do |table_name, count|
|
396
|
-
next unless File.exists?(File.join(dump_path, "data", "#{table_name}.json")) || JSON.parse(File.read(File.join(dump_path, "data", "#{
|
399
|
+
next unless File.exists?(File.join(dump_path, "data", "#{table_name}.json")) || File.exists?(File.join(dump_path, "data", "#{table_name}.json")) && JSON.parse(File.read(File.join(dump_path, "data", "#{table_name}.json")))["data"].size == 0
|
397
400
|
db[table_name.to_sym].truncate if @opts[:purge]
|
398
401
|
stream = Tapsoob::DataStream.factory(db, {
|
399
402
|
:table_name => table_name,
|
data/lib/tapsoob/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tapsoob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.27
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Félix Bellanger
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-01-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|