dbagent 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/db_agent/db_handler.rb +1 -1
- data/lib/db_agent/seeder.rb +26 -1
- data/lib/db_agent/version.rb +1 -1
- data/tasks/db.rake +6 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb16765f4f64bec5eff152e6db516bb5b672348a1b909229ce46e024b37132ab
|
4
|
+
data.tar.gz: 48b7d28235340c73b316aabba304a20ccf854cdea919eecca1c7f19b1f594487
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61ee06b3ca6734ed61889878e2806eaa5774d08cd864b3ca2a1b90acaf22d505d830fbfb01b96c50340e2c1b27462e658efe2a7db54a2e4243873f912ddb3762
|
7
|
+
data.tar.gz: 786ada66e5e8ea0e584e8ef61a36f71134df08fca60b50b3da6fd35e06db76c904c2814db1b2f21a3beb921485983840cd8a34b218dd558e23e0ce839f724f47
|
data/lib/db_agent/db_handler.rb
CHANGED
data/lib/db_agent/seeder.rb
CHANGED
@@ -18,11 +18,13 @@ module DbAgent
|
|
18
18
|
pairs[p1].basename <=> pairs[p2].basename
|
19
19
|
}
|
20
20
|
|
21
|
-
# Truncate tables
|
21
|
+
# Truncate tables
|
22
22
|
names.reverse.each do |name|
|
23
23
|
LOGGER.info("Emptying table `#{name}`")
|
24
24
|
handler.sequel_db[name.to_sym].delete
|
25
25
|
end
|
26
|
+
|
27
|
+
# Fill them
|
26
28
|
names.each do |name|
|
27
29
|
LOGGER.info("Filling table `#{name}`")
|
28
30
|
file = pairs[name]
|
@@ -33,6 +35,29 @@ module DbAgent
|
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
38
|
+
def insert_script(from)
|
39
|
+
folder = handler.data_folder/from
|
40
|
+
|
41
|
+
# load files in order
|
42
|
+
pairs = merged_data(from)
|
43
|
+
names = pairs.keys.sort{|p1,p2|
|
44
|
+
pairs[p1].basename <=> pairs[p2].basename
|
45
|
+
}
|
46
|
+
|
47
|
+
# Fill them
|
48
|
+
names.each do |name|
|
49
|
+
file = pairs[name]
|
50
|
+
data = file.load
|
51
|
+
next if data.empty?
|
52
|
+
|
53
|
+
keys = data.first.keys
|
54
|
+
values = data.map{|t|
|
55
|
+
keys.map{|k| t[k] }
|
56
|
+
}
|
57
|
+
puts handler.sequel_db[name.to_sym].multi_insert_sql(keys, values)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
36
61
|
def flush_empty(to = "empty")
|
37
62
|
target = (handler.data_folder/to).rm_rf.mkdir_p
|
38
63
|
(target/"metadata.json").write <<-JSON.strip
|
data/lib/db_agent/version.rb
CHANGED
data/tasks/db.rake
CHANGED
@@ -81,6 +81,12 @@ namespace :db do
|
|
81
81
|
end
|
82
82
|
task :seed => :require
|
83
83
|
|
84
|
+
desc "Prints an INSERT script for a particular data set"
|
85
|
+
task :insert_script, :from do |t,args|
|
86
|
+
Seeder.new(db_handler).insert_script(args[:from] || 'empty')
|
87
|
+
end
|
88
|
+
task :insert_script => :require
|
89
|
+
|
84
90
|
desc "Flushes the database as a particular data set"
|
85
91
|
task :flush, :to do |t,args|
|
86
92
|
Seeder.new(db_handler).flush(args[:to] || Time.now.strftime("%Y%M%d%H%M%S").to_s)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbagent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Lambeau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -229,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
229
|
- !ruby/object:Gem::Version
|
230
230
|
version: '0'
|
231
231
|
requirements: []
|
232
|
-
rubygems_version: 3.1.
|
232
|
+
rubygems_version: 3.1.6
|
233
233
|
signing_key:
|
234
234
|
specification_version: 4
|
235
235
|
summary: A tool to migrate, spy and seed relational databases.
|