tapsoob 0.3.21-java → 0.3.22-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tapsoob/cli/root.rb +3 -1
- data/lib/tapsoob/data_stream.rb +7 -3
- data/lib/tapsoob/operation.rb +2 -2
- data/lib/tapsoob/version.rb +1 -1
- 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: '0902657538025d8da02f1bcfe8d15b8e14746bb56083cc021044f25aa4e81f24'
|
4
|
+
data.tar.gz: 41a7f3a480214954e2d06869f094e38b73ac79ba59e38b17b6c06d9a37a991cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42f9ca1dd0dd01eb5f257b30e8872db9bf6de0606453a74558d0be1094abfeae036f0394d32c73fb6a99ed19e383e4dbddae0ab63a90d33d04c015096564664e
|
7
|
+
data.tar.gz: 2f42ab39fbb77d28620c4b174429fc8d1861e5a11a708c34ddece07a809f1a5d4e436dbf1e9bed8e3ce925421a7439c1098f5f60d135b10ed813144dddcf512d
|
data/lib/tapsoob/cli/root.rb
CHANGED
@@ -39,6 +39,7 @@ module Tapsoob
|
|
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"
|
42
|
+
option :"discard-identity", desc: "Remove identity when pushing data (may result in creating duplicates)", default: false, type: :boolean
|
42
43
|
option :debug, desc: "Enable debug messages", default: false, type: :boolean, aliases: "-d"
|
43
44
|
def push(dump_path, database_url)
|
44
45
|
opts = parse_opts(options)
|
@@ -71,8 +72,9 @@ module Tapsoob
|
|
71
72
|
debug: options[:debug]
|
72
73
|
}
|
73
74
|
|
74
|
-
#
|
75
|
+
# Push only options
|
75
76
|
opts[:purge] = options[:purge] if options.key?(:purge)
|
77
|
+
opts[:"discard-identity"] = options[:"discard-identity"] if options.key?(:"discard-identity")
|
76
78
|
|
77
79
|
# Resume
|
78
80
|
if options[:resume]
|
data/lib/tapsoob/data_stream.rb
CHANGED
@@ -6,9 +6,9 @@ module Tapsoob
|
|
6
6
|
class DataStream
|
7
7
|
DEFAULT_CHUNKSIZE = 1000
|
8
8
|
|
9
|
-
attr_reader :db, :state
|
9
|
+
attr_reader :db, :state, :options
|
10
10
|
|
11
|
-
def initialize(db, state)
|
11
|
+
def initialize(db, state, opts = {})
|
12
12
|
@db = db
|
13
13
|
@state = {
|
14
14
|
:offset => 0,
|
@@ -17,6 +17,7 @@ module Tapsoob
|
|
17
17
|
:total_chunksize => 0
|
18
18
|
}.merge(state)
|
19
19
|
@state[:chunksize] ||= DEFAULT_CHUNKSIZE
|
20
|
+
@options = opts
|
20
21
|
@complete = false
|
21
22
|
end
|
22
23
|
|
@@ -227,8 +228,11 @@ module Tapsoob
|
|
227
228
|
end
|
228
229
|
end
|
229
230
|
end
|
231
|
+
|
232
|
+
# Remove id column
|
233
|
+
columns = ((@options[:"discard-identity"] && rows[:headers].include?("id")) ? rows[:headers] - ["id"] : rows[:headers])
|
230
234
|
|
231
|
-
table.import(
|
235
|
+
table.import(columns, rows[:data], :commit_every => 100)
|
232
236
|
state[:offset] += rows[:data].size
|
233
237
|
rescue Exception => ex
|
234
238
|
case ex.message
|
data/lib/tapsoob/operation.rb
CHANGED
@@ -394,9 +394,9 @@ module Tapsoob
|
|
394
394
|
tables.each do |table_name, count|
|
395
395
|
next unless File.exists?(File.join(dump_path, "data", "#{table_name}.json"))
|
396
396
|
db[table_name.to_sym].truncate if @opts[:purge]
|
397
|
-
stream = Tapsoob::DataStream.factory(db,
|
397
|
+
stream = Tapsoob::DataStream.factory(db, {
|
398
398
|
:table_name => table_name,
|
399
|
-
:chunksize => default_chunksize)
|
399
|
+
:chunksize => default_chunksize }, { :"discard-identity" => @opts[:"discard-identity"] || false })
|
400
400
|
progress = ProgressBar.new(table_name.to_s, count)
|
401
401
|
push_data_from_file(stream, progress)
|
402
402
|
end
|
data/lib/tapsoob/version.rb
CHANGED