avm-eac_postgresql_base0 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2a67a8652cd229c20b08aa095b294e21d423f02b0b861d1bfcccd5c54fcfc74
4
- data.tar.gz: 5a07165d40bac4706e20e39e6eedc72fcafb49c8da1ce9bcabdfe8092d1b89ef
3
+ metadata.gz: 84e0a14809137d8b08980f06cb62e81f4ea0142bd3d7c0f3d646a906f49be832
4
+ data.tar.gz: 8e3f20b69e7af8cc0e4a1445438d0a3696c60bc8debdf9654e180a1c1f51662e
5
5
  SHA512:
6
- metadata.gz: 9a25af8a2ff07eb69af5fff54bacfc45b23d0c33752ed92355e07fc7a0da062ad2cc5e04ff9386722e2d6cda6e722b7837f891224d07ed7ad4a1258fb3e51c64
7
- data.tar.gz: 0af9592a57753fd6b46a18323a7e33a44fc4740d6d3dea72bc32bb73c7f737585e885ad70c23e8e0c63b09ac035d757f66662b47dabb842bd89ace7ecace2b11
6
+ metadata.gz: 520e4c244648f74bd1ba2f870abe3e6e3f4c58d22bf06f4c0b04e6dd926fc401f1e6d7492bfaa37c2a77d52683c85b522c4d74ed60b8824fa99823ca762885c3
7
+ data.tar.gz: 6c47c1cb2dec4acd690ce7ff7750f38f29b11c5714e2191ceff4cba4601c5da7669ed7f4c1b1058da87a0e5eecd35f2de70e841bee92032f0393ad205b3191a2
@@ -7,6 +7,7 @@ module Avm
7
7
  class Instance
8
8
  class DataUnit < ::Avm::Instances::Data::Unit
9
9
  EXTENSION = '.pgdump.gz'
10
+ TABLES_SQL = 'select tablename from pg_tables where schemaname = \'public\''
10
11
 
11
12
  before_load :clear_database
12
13
 
@@ -15,24 +16,29 @@ module Avm
15
16
  end
16
17
 
17
18
  def load_command
18
- instance.psql_command.prepend(['gzip', '-d', '@ESC_|'])
19
+ instance.load_gzip_command
19
20
  end
20
21
 
21
22
  private
22
23
 
23
24
  def clear_database
24
25
  info 'Clearing database (Dropping all tables)...'
25
- run_sql(drop_all_tables_sql).if_present { |v| run_sql(v) }
26
- end
27
-
28
- def drop_all_tables_sql
29
- "select 'drop table \"' || tablename || '\" cascade;' from pg_tables " \
30
- "where schemaname = 'public';"
26
+ ts = tables
27
+ if ts.empty?
28
+ info 'Database has no tables'
29
+ else
30
+ info "Removing #{ts.count} table(s)..."
31
+ run_sql('drop table ' + ts.map { |t| "\"#{t}\"" }.join(', ') + ' cascade')
32
+ end
31
33
  end
32
34
 
33
35
  def run_sql(sql)
34
36
  instance.psql_command_command(sql).execute!
35
37
  end
38
+
39
+ def tables
40
+ run_sql(TABLES_SQL).each_line.map(&:strip).reject(&:blank?)
41
+ end
36
42
  end
37
43
  end
38
44
  end
@@ -29,7 +29,22 @@ module Avm
29
29
 
30
30
  # @return [EacRubyUtils::Envs::Command]
31
31
  def dump_gzip_command
32
- dump_command.pipe(env.command('gzip', '-9', '-c'))
32
+ dump_command.pipe(gzip_compress_command)
33
+ end
34
+
35
+ # @return [EacRubyUtils::Envs::Command]
36
+ def gzip_compress_command
37
+ env.command('gzip', '-9', '-c')
38
+ end
39
+
40
+ # @return [EacRubyUtils::Envs::Command]
41
+ def gzip_decompress_command
42
+ env.command('gzip', '-d')
43
+ end
44
+
45
+ # @return [EacRubyUtils::Envs::Command]
46
+ def load_gzip_command
47
+ gzip_decompress_command.pipe(psql_command)
33
48
  end
34
49
 
35
50
  # @return [String]
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacPostgresqlBase0
5
- VERSION = '0.2.2'
5
+ VERSION = '0.2.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-eac_postgresql_base0
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Put here the authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-24 00:00:00.000000000 Z
11
+ date: 2022-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.108'
33
+ version: '0.109'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.108'
40
+ version: '0.109'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: eac_ruby_gem_support
43
43
  requirement: !ruby/object:Gem::Requirement