avm-eac_postgresql_base0 0.2.2 → 0.2.4

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: e2a67a8652cd229c20b08aa095b294e21d423f02b0b861d1bfcccd5c54fcfc74
4
- data.tar.gz: 5a07165d40bac4706e20e39e6eedc72fcafb49c8da1ce9bcabdfe8092d1b89ef
3
+ metadata.gz: 03a08a9048593955e5cc62a604c6dfc94e21abe79e995d1933a3de00b908f18a
4
+ data.tar.gz: d29c537ded1c570897830df081f2c36f5101f5e3f508392e7279e21743465709
5
5
  SHA512:
6
- metadata.gz: 9a25af8a2ff07eb69af5fff54bacfc45b23d0c33752ed92355e07fc7a0da062ad2cc5e04ff9386722e2d6cda6e722b7837f891224d07ed7ad4a1258fb3e51c64
7
- data.tar.gz: 0af9592a57753fd6b46a18323a7e33a44fc4740d6d3dea72bc32bb73c7f737585e885ad70c23e8e0c63b09ac035d757f66662b47dabb842bd89ace7ecace2b11
6
+ metadata.gz: 55b5a9708048a4d3fc467db99a3960e0dca5c505fdc8e07d3933c542fe0665532f5006ba3faa8bdd3f58ae0cdeedac3bea1c210056a59e7ec45a759d9c8de69d
7
+ data.tar.gz: e3d579fc45bda1bea8666ca036989b6bd684348668edebdffb5b699add72e38e20e15a55d0b911d52d5d4fc9fdc084d3d9512fcceacb99edfe8da43353515d46
@@ -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 if exists ' + 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.4'
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.4
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: 2023-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm
@@ -16,28 +16,34 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.57'
19
+ version: '0.66'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.66.1
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: '0.57'
29
+ version: '0.66'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.66.1
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: eac_ruby_utils
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: '0.108'
39
+ version: '0.112'
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
44
  - - "~>"
39
45
  - !ruby/object:Gem::Version
40
- version: '0.108'
46
+ version: '0.112'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: eac_ruby_gem_support
43
49
  requirement: !ruby/object:Gem::Requirement