dbagent 3.3.0 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/db_agent/db_handler/mssql.rb +14 -2
- data/lib/db_agent/db_handler/mysql.rb +15 -3
- data/lib/db_agent/db_handler/postgresql.rb +6 -2
- data/lib/db_agent/db_handler.rb +20 -6
- data/lib/db_agent/version.rb +1 -1
- 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: d63bf0c7e2699b356813cd4d71eb28a812a0432e5dc39f8b3b4097b0e63e0664
|
4
|
+
data.tar.gz: 19b4815533138bd1a3544366bde4b7ee40daeb963268836c956a1b5abbd38915
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19d9883a82ad142391cbf3fdb0c06177ddb3b72495c0ce3d48aaaa178a3bbf7529692a6c8622e17daf70807e848e6dce288026a041e520fb06cf30daccbe088a
|
7
|
+
data.tar.gz: be304ecb123c8933fa16f606178fb65d3a29d0eedec042dae449a39a092eae371dad06efe78625cdc83a1011eea5c78c7889c904ac6f27c5434a886de9d6a6e1
|
data/README.md
CHANGED
@@ -31,6 +31,7 @@ See the examples folder for details.
|
|
31
31
|
* `DBAGENT_SUPER_USER` Superuser name (postgres only)
|
32
32
|
* `DBAGENT_SUPER_DB` Superuser database (postgres only)
|
33
33
|
* `DBAGENT_SUPER_PASSWORD` Superuser password (postgres only)
|
34
|
+
* `DBAGENT_WAIT_TIMEOUT_IN_SEC` Timeout in seconds before db:wait_server and db:wait give up
|
34
35
|
* `DBAGENT_VIEWPOINT` Bmg viewpoint (class name) when using db:flush
|
35
36
|
|
36
37
|
## Available rake tasks
|
@@ -51,6 +52,8 @@ rake db:spy # Dumps the schema documentation into database/schema
|
|
51
52
|
rake db:backup # Makes a database backup to the backups folder
|
52
53
|
rake db:restore[match] # Restore the last matching database backup file from backups folder
|
53
54
|
rake db:revive # Shortcut for both db:restore and db:migrate
|
55
|
+
rake db:wait_server # Waits until the postgresql host seems available
|
56
|
+
rake db:wait # Waits until the postgresql database seems available
|
54
57
|
rake db:tables # List tables with those with fewer dependencies first
|
55
58
|
rake db:dependencies[of] # List tables that depend of a given one
|
56
59
|
```
|
@@ -19,8 +19,20 @@ module DbAgent
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def spy
|
22
|
-
|
23
|
-
|
22
|
+
spy_jar = DbAgent._!('vendor').glob('schema*.jar').first
|
23
|
+
jdbc_jar = DbAgent._!('vendor').glob('mssql*.jar').first
|
24
|
+
cmd = ""
|
25
|
+
cmd << %Q{java -jar #{spy_jar}}
|
26
|
+
cmd << %Q{ -dp #{jdbc_jar} -t mssql05}
|
27
|
+
cmd << %Q{ -host #{config[:host]}}
|
28
|
+
cmd << %Q{ -u #{config[:user]}}
|
29
|
+
cmd << %Q{ -p #{config[:password]}}
|
30
|
+
cmd << %Q{ -db #{config[:database]}}
|
31
|
+
cmd << %Q{ -port #{config[:port]}}
|
32
|
+
cmd << %Q{ -s dbo}
|
33
|
+
cmd << %Q{ -o #{schema_folder}/spy}
|
34
|
+
cmd << %Q{ #{ENV['SCHEMA_SPY_ARGS']}} if ENV['SCHEMA_SPY_ARGS']
|
35
|
+
system(cmd)
|
24
36
|
system %Q{open #{schema_folder}/spy/index.html}
|
25
37
|
end
|
26
38
|
|
@@ -21,9 +21,21 @@ module DbAgent
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def spy
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
spy_jar = DbAgent._!('vendor').glob('schema*.jar').first
|
25
|
+
jdbc_jar = DbAgent._!('vendor').glob('mysql*.jar').first
|
26
|
+
cmd = ""
|
27
|
+
cmd << %Q{java -jar #{spy_jar}}
|
28
|
+
cmd << %Q{ -dp #{jdbc_jar} -t mysql}
|
29
|
+
cmd << %Q{ -host #{config[:host]}}
|
30
|
+
cmd << %Q{ -u #{config[:user]}}
|
31
|
+
cmd << %Q{ -p #{config[:password]}}
|
32
|
+
cmd << %Q{ -db #{config[:database]}}
|
33
|
+
cmd << %Q{ -port #{config[:port]}}
|
34
|
+
cmd << %Q{ -s public}
|
35
|
+
cmd << %Q{ -o #{schema_folder}/spy}
|
36
|
+
cmd << %Q{ #{ENV['SCHEMA_SPY_ARGS']}} if ENV['SCHEMA_SPY_ARGS']
|
37
|
+
system(cmd)
|
38
|
+
system %Q{open #{schema_folder}/spy/index.html}
|
27
39
|
end
|
28
40
|
|
29
41
|
def restore(_t, args)
|
@@ -25,12 +25,16 @@ module DbAgent
|
|
25
25
|
spy_jar = DbAgent._!('vendor').glob('schema*.jar').first
|
26
26
|
jdbc_jar = DbAgent._!('vendor').glob('postgresql*.jar').first
|
27
27
|
cmd = ""
|
28
|
-
cmd << %Q{java -jar #{spy_jar}
|
28
|
+
cmd << %Q{java -jar #{spy_jar}}
|
29
|
+
cmd << %Q{ -dp #{jdbc_jar} -t pgsql}
|
29
30
|
cmd << %Q{ -host #{config[:host]}}
|
30
31
|
cmd << %Q{ -port #{config[:port]}} if config[:port]
|
31
32
|
cmd << %Q{ -u #{config[:user]}}
|
32
33
|
cmd << %Q{ -p #{config[:password]}} if config[:password]
|
33
|
-
cmd << %Q{ -db #{config[:database]}
|
34
|
+
cmd << %Q{ -db #{config[:database]}}
|
35
|
+
cmd << %Q{ -s public}
|
36
|
+
cmd << %Q{ -o #{schema_folder}/spy}
|
37
|
+
cmd << %Q{ #{ENV['SCHEMA_SPY_ARGS']}} if ENV['SCHEMA_SPY_ARGS']
|
34
38
|
system(cmd)
|
35
39
|
system %Q{open #{schema_folder}/spy/index.html}
|
36
40
|
end
|
data/lib/db_agent/db_handler.rb
CHANGED
@@ -42,8 +42,8 @@ module DbAgent
|
|
42
42
|
require 'net/ping'
|
43
43
|
raise "No host found" unless config[:host]
|
44
44
|
check = Net::Ping::External.new(config[:host])
|
45
|
-
|
46
|
-
|
45
|
+
print "Trying to ping `#{config[:host]}`\n"
|
46
|
+
wait_timeout_in_seconds.downto(0) do |i|
|
47
47
|
print "."
|
48
48
|
if check.ping?
|
49
49
|
print "\nServer found.\n"
|
@@ -58,14 +58,18 @@ module DbAgent
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def wait
|
61
|
-
|
61
|
+
print "Using #{config}\n"
|
62
|
+
wait_timeout_in_seconds.downto(0) do |i|
|
63
|
+
print "."
|
62
64
|
begin
|
63
|
-
puts "Using #{config}"
|
64
65
|
sequel_db.test_connection
|
65
|
-
|
66
|
+
print "\nDatabase is there. Great.\n"
|
66
67
|
break
|
67
68
|
rescue Sequel::Error
|
68
|
-
|
69
|
+
if i==0
|
70
|
+
print "\n"
|
71
|
+
raise
|
72
|
+
end
|
69
73
|
sleep(1)
|
70
74
|
end
|
71
75
|
end
|
@@ -123,6 +127,16 @@ module DbAgent
|
|
123
127
|
Path.require_tree(f) if f.directory?
|
124
128
|
end
|
125
129
|
|
130
|
+
private
|
131
|
+
|
132
|
+
def wait_timeout_in_seconds
|
133
|
+
(ENV['DBAGENT_WAIT_TIMEOUT_IN_SEC'] || '15').to_i
|
134
|
+
end
|
135
|
+
|
136
|
+
def print(*args)
|
137
|
+
super.tap{ $stdout.flush }
|
138
|
+
end
|
139
|
+
|
126
140
|
end # class DbHandler
|
127
141
|
end # module DbAgent
|
128
142
|
require_relative 'db_handler/postgresql'
|
data/lib/db_agent/version.rb
CHANGED
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.5.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: 2023-
|
11
|
+
date: 2023-06-19 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.
|
232
|
+
rubygems_version: 3.4.6
|
233
233
|
signing_key:
|
234
234
|
specification_version: 4
|
235
235
|
summary: A tool to migrate, spy and seed relational databases.
|