avm-eac_postgresql_base0 0.5.1 → 0.5.3

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: 2264f776064ed8277f18dc9bf8b1709917ac80761a6e72ed9101445ef6d91b79
4
- data.tar.gz: da0725910f7a61738ae7af19f0d31c7fe5a8fcd612c740231ca9412ba672c105
3
+ metadata.gz: b225a9cd207947f745ff37aaa23d898088217ff8787076ee9752407c81cbca86
4
+ data.tar.gz: 375aab52990242c88133d75b04d84b8ba1b8fbcada204413317e1959e92aa105
5
5
  SHA512:
6
- metadata.gz: 6d9229e8f4cb7df168f1f963d42d109dacdc88da81d9f5ecd0547493573bbf0d4e77aea98b5259907db30cf81d0dfe93847a67dd398c877111fbbcc4a0ebb509
7
- data.tar.gz: da16356cfbbcd62084a58d92f34ac1036633bc44deb0fe0d9fd277900f32f13a528204ed02ec1ce1ad32a6517859f8319d758e093c032b6407564f3d662ca3be
6
+ metadata.gz: 8b98c338d49e17da1a7da5c7697e3e83403bbbaff559e9ef1b58a16ffabe556e971c421cc8ce4f3f19dfc49af2ee802e83ee1797458a619337c0105991a7598d
7
+ data.tar.gz: 0a6a68ac3769c9c011a35f07c1486ef15318e3b5122b923b34baf4b3403f2544a5d3eab36ae946184df0323fffbe44360d6f80ee876eb7a45028190ecfa928ac
@@ -29,7 +29,7 @@ module Avm
29
29
  end
30
30
 
31
31
  def current_owner
32
- root_query(<<~SQL
32
+ root_query(<<~SQL.squish
33
33
  SELECT pg_catalog.pg_get_userbyid(datdba)
34
34
  FROM pg_catalog.pg_database
35
35
  WHERE datname = '#{name}'
@@ -43,7 +43,7 @@ module Avm
43
43
 
44
44
  def password_ok?
45
45
  instance.psql_command_command('SELECT 1', false)
46
- .execute!(exit_outputs: { 512 => 'login_failed' }).strip == '1'
46
+ .execute!(exit_outputs: { 512 => 'login_failed' }).strip == '1'
47
47
  end
48
48
 
49
49
  def user_exist?
@@ -7,13 +7,13 @@ module Avm
7
7
  module EacPostgresqlBase0
8
8
  class Instance
9
9
  module Commands
10
- DUMP_EXCLUDE_PATTERN = '^(CREATE|COMMENT ON) EXTENSION'
10
+ DUMP_EXCLUDE_PATTERNS = ['(CREATE|COMMENT ON) EXTENSION',
11
+ 'SET default_table_access_method'].freeze
11
12
 
12
13
  # @return [EacRubyUtils::Envs::Command]
13
14
  def dump_command
14
- env.command('pg_dump', '--no-privileges', '--no-owner', *common_command_args)
15
- .envvar('PGPASSWORD', password)
16
- .pipe(remove_extensions_ddl)
15
+ DUMP_EXCLUDE_PATTERNS
16
+ .inject(pg_dump_command) { |a, e| a.pipe(exclude_pattern_command(e)) }
17
17
  end
18
18
 
19
19
  # @return [EacRubyUtils::Envs::Command]
@@ -41,12 +41,12 @@ module Avm
41
41
  "@ESC_PGPASSWORD=#{password}"
42
42
  end
43
43
 
44
- def psql_command(database = true)
44
+ def psql_command(database = true) # rubocop:disable Style/OptionalBooleanParameter
45
45
  env.command(password_command_argument, 'psql', '--variable', 'ON_ERROR_STOP=t',
46
46
  *common_command_args(database))
47
47
  end
48
48
 
49
- def psql_command_command(sql, database = true)
49
+ def psql_command_command(sql, database = true) # rubocop:disable Style/OptionalBooleanParameter
50
50
  psql_command(database).append(['--quiet', '--tuples-only', '--command', sql])
51
51
  end
52
52
 
@@ -56,7 +56,7 @@ module Avm
56
56
  env.command(*args)
57
57
  end
58
58
 
59
- def common_command_args(database = true)
59
+ def common_command_args(database = true) # rubocop:disable Style/OptionalBooleanParameter
60
60
  ['--host', host, '--username', user, '--port', port,
61
61
  (database ? name : MAINTENANCE_DATABASE)]
62
62
  end
@@ -64,8 +64,14 @@ module Avm
64
64
  private
65
65
 
66
66
  # @return [EacRubyUtils::Envs::Command]
67
- def remove_extensions_ddl
68
- env.command('grep', '--invert-match', '--extended-regexp', DUMP_EXCLUDE_PATTERN)
67
+ def exclude_pattern_command(pattern)
68
+ env.command('sed', '--regexp-extended', "s/(^|\\n)#{pattern}[^;]*;//gm")
69
+ end
70
+
71
+ # @return [EacRubyUtils::Envs::Command]
72
+ def pg_dump_command
73
+ env.command('pg_dump', '--no-privileges', '--no-owner', *common_command_args)
74
+ .envvar('PGPASSWORD', password)
69
75
  end
70
76
  end
71
77
  end
@@ -10,7 +10,7 @@ module Avm
10
10
  SCHEMA_VAR = '%%SCHEMA%%'
11
11
  TABLE_PARTS_SEPARATOR = '/'
12
12
  TABLES_SQL = "select schemaname || '#{TABLE_PARTS_SEPARATOR}' || tablename from " \
13
- "pg_tables where schemaname = '#{SCHEMA_VAR}'"
13
+ "pg_tables where schemaname = '#{SCHEMA_VAR}'"
14
14
 
15
15
  def do_clear
16
16
  ts = tables
@@ -35,7 +35,7 @@ module Avm
35
35
  # @param table_list [Array<String>]
36
36
  # @return [String]
37
37
  def drop_tables_sql(table_list)
38
- 'drop table ' + table_list.map(&:to_s).join(', ') + ' cascade'
38
+ "drop table #{table_list.map(&:to_s).join(', ')} cascade"
39
39
  end
40
40
 
41
41
  # @param parts [Array<String>, Strings]
@@ -51,8 +51,8 @@ module Avm
51
51
 
52
52
  # @return [Array<String>]
53
53
  def tables
54
- run_sql(tables_sql).each_line.map(&:strip).reject(&:blank?)
55
- .map { |line| join_table_parts(line) }
54
+ run_sql(tables_sql).each_line.map(&:strip).compact_blank
55
+ .map { |line| join_table_parts(line) }
56
56
  end
57
57
 
58
58
  # @return [String]
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacPostgresqlBase0
5
- VERSION = '0.5.1'
5
+ VERSION = '0.5.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.5.1
4
+ version: 0.5.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: 2023-05-12 00:00:00.000000000 Z
11
+ date: 2024-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.71'
19
+ version: '0.85'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.71'
26
+ version: '0.85'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: eac_ruby_utils
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.115'
33
+ version: '0.121'
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.115'
40
+ version: '0.121'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: eac_ruby_gem_support
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.5.1
47
+ version: '0.10'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.5.1
54
+ version: '0.10'
55
55
  description:
56
56
  email:
57
57
  executables: []
@@ -76,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
76
  requirements:
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- version: '0'
79
+ version: '2.7'
80
80
  required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - ">="