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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb16765f4f64bec5eff152e6db516bb5b672348a1b909229ce46e024b37132ab
4
- data.tar.gz: 48b7d28235340c73b316aabba304a20ccf854cdea919eecca1c7f19b1f594487
3
+ metadata.gz: d63bf0c7e2699b356813cd4d71eb28a812a0432e5dc39f8b3b4097b0e63e0664
4
+ data.tar.gz: 19b4815533138bd1a3544366bde4b7ee40daeb963268836c956a1b5abbd38915
5
5
  SHA512:
6
- metadata.gz: 61ee06b3ca6734ed61889878e2806eaa5774d08cd864b3ca2a1b90acaf22d505d830fbfb01b96c50340e2c1b27462e658efe2a7db54a2e4243873f912ddb3762
7
- data.tar.gz: 786ada66e5e8ea0e584e8ef61a36f71134df08fca60b50b3da6fd35e06db76c904c2814db1b2f21a3beb921485983840cd8a34b218dd558e23e0ce839f724f47
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
- jdbc_jar = (Path.dir.parent/'vendor').glob('mssql*.jar').first
23
- system %Q{java -jar vendor/schemaSpy_5.0.0.jar -dp #{jdbc_jar} -t mssql05 -host #{config[:host]} -u #{config[:user]} -p #{config[:password]} -db #{config[:database]} -port #{config[:port]} -s dbo -o #{schema_folder}/spy}
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
- jdbc_jar = (Path.dir.parent / 'vendor').glob('mysql*.jar').first
25
- system %(java -jar vendor/schemaSpy_5.0.0.jar -dp #{jdbc_jar} -t mysql -host #{config[:host]} -u #{config[:user]} -p #{config[:password]} -db #{config[:database]} -s public -o #{schema_folder}/spy)
26
- system %(open #{schema_folder}/spy/index.html)
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} -dp #{jdbc_jar} -t pgsql}
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]} -s public -o #{schema_folder}/spy}
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
@@ -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
- puts "Trying to ping `#{config[:host]}`"
46
- 15.downto(0) do |i|
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
- 15.downto(0) do |i|
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
- puts "Database is there. Great."
66
+ print "\nDatabase is there. Great.\n"
66
67
  break
67
68
  rescue Sequel::Error
68
- raise if i==0
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'
@@ -1,6 +1,6 @@
1
1
  module DbAgent
2
2
 
3
3
  # Current version of DbAgent
4
- VERSION = "3.3.0"
4
+ VERSION = "3.5.0"
5
5
 
6
6
  end
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.3.0
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-04-17 00:00:00.000000000 Z
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.1.6
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.