data_keeper 0.2.0 → 0.2.1

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: 1f0067051d0aa4c4a42aba134510233f0b8cd9acdbc4fe07a827df4af1fbd48c
4
- data.tar.gz: 67bae8fe0fb71d313229da366e47173ff06f0c0ffcf082d4f6743722be66c500
3
+ metadata.gz: 1ea02e8856f7dbdcc74cd8c82a57893d792a6a2aeb5c6963258d06b8707e9a2b
4
+ data.tar.gz: a6dbcdc1d8266d8a554ab6b7b1650dad9b810b5f91f8be3da1f157a877e537e9
5
5
  SHA512:
6
- metadata.gz: 33aa3ca995eef2f037bb4a2dfdfba5dc207d3265eb9a4ccc0568d592ed1ab3f609bd49ad3bc9732283a52814daa443302e125be1ae4219001d9e14f44e7084bf
7
- data.tar.gz: 9a6a28ef62cf97960031c9b73d5d02aa942120692155c340dd7b73539d9df5c3695dd981c13bf15a8a6d04afef730f5c2ce1e4dee4c18851218ff8c81faa4e68
6
+ metadata.gz: cb567b6fd35e1c68f051ee3b06e712dd9ed17e9895362ac7f025940b74cff0973255b51d95cd1effb91a67a7bd92188e50a30a07bc77e1f354008fbeab9f1d39
7
+ data.tar.gz: eab10951b2cf77197c6d360d2676726ea01ddfc9c6696647e96806724d7cdaf370e33f046fbc2620ee1753b7ad697200e28d932ec45bb550bbd19a655f9b5f1b
@@ -10,12 +10,26 @@ module DataKeeper
10
10
  env
11
11
  end
12
12
 
13
+ def dumper_psql_env
14
+ env = { 'PGUSER' => server_username }
15
+ env['PGPASSWORD'] = server_password if server_password
16
+ env
17
+ end
18
+
13
19
  def docker_env_params
14
20
  psql_env.map do |k, v|
15
21
  "-e #{k}=#{v}"
16
22
  end.join(" ")
17
23
  end
18
24
 
25
+ def server_username
26
+ database_connection_config['username']
27
+ end
28
+
29
+ def server_password
30
+ database_connection_config['password']
31
+ end
32
+
19
33
  def username
20
34
  DataKeeper.docker_config[:pg_user] || database_connection_config['username']
21
35
  end
@@ -36,10 +50,20 @@ module DataKeeper
36
50
  DataKeeper.docker_config[:pg_port] || database_connection_config['port'] || '5432'
37
51
  end
38
52
 
53
+ def server_port
54
+ database_connection_config['port'] || '5432'
55
+ end
56
+
39
57
  def connection_args
40
58
  connection_opts = '--host=:host'
41
59
  connection_opts += ' --port=:port' if port
42
60
  connection_opts
43
61
  end
62
+
63
+ def dumper_connection_args
64
+ connection_opts = '--host=:host'
65
+ connection_opts += ' --port=:port' if server_port
66
+ connection_opts
67
+ end
44
68
  end
45
69
  end
@@ -24,8 +24,8 @@ module DataKeeper
24
24
  Tempfile.create do |file|
25
25
  cmd = Terrapin::CommandLine.new(
26
26
  'pg_dump',
27
- "#{connection_args} -x -Fc :database > :output_path",
28
- environment: psql_env
27
+ "#{dumper_connection_args} -x -Fc :database > :output_path",
28
+ environment: dumper_psql_env
29
29
  )
30
30
 
31
31
  cmd.run(
@@ -61,8 +61,8 @@ module DataKeeper
61
61
  Tempfile.create do |table_file|
62
62
  cmd = Terrapin::CommandLine.new(
63
63
  'psql',
64
- "#{connection_args} -d :database -c :command > #{table_file.path}",
65
- environment: psql_env
64
+ "#{dumper_connection_args} -d :database -c :command > #{table_file.path}",
65
+ environment: dumper_psql_env
66
66
  )
67
67
 
68
68
  cmd.run(
@@ -89,8 +89,8 @@ module DataKeeper
89
89
  table_args = @definition.full_tables_to_export.map { |table| "-t #{table}" }.join(' ')
90
90
  cmd = Terrapin::CommandLine.new(
91
91
  'pg_dump',
92
- "#{connection_args} -x -Fc :database #{table_args} > :output_path",
93
- environment: psql_env
92
+ "#{dumper_connection_args} -x -Fc :database #{table_args} > :output_path",
93
+ environment: dumper_psql_env
94
94
  )
95
95
 
96
96
  cmd.run(
@@ -116,8 +116,8 @@ module DataKeeper
116
116
 
117
117
  cmd = Terrapin::CommandLine.new(
118
118
  'pg_dump',
119
- "#{connection_args} -x --schema-only -Fc :database > :output_path",
120
- environment: psql_env
119
+ "#{dumper_connection_args} -x --schema-only -Fc :database > :output_path",
120
+ environment: dumper_psql_env
121
121
  )
122
122
 
123
123
  cmd.run(
@@ -144,8 +144,8 @@ module DataKeeper
144
144
  sequences_args = all_sequences_to_export.map { |table| "-t #{table}" }.join(' ')
145
145
  cmd = Terrapin::CommandLine.new(
146
146
  'pg_dump',
147
- "#{connection_args} -x -Fc :database #{sequences_args} > :output_path",
148
- environment: psql_env
147
+ "#{dumper_connection_args} -x -Fc :database #{sequences_args} > :output_path",
148
+ environment: dumper_psql_env
149
149
  )
150
150
 
151
151
  cmd.run(database: database, host: host, port: port, output_path: sequences_dump_file.path)
@@ -167,8 +167,8 @@ module DataKeeper
167
167
  def all_sequences_to_export
168
168
  cmd = Terrapin::CommandLine.new(
169
169
  'psql',
170
- "#{connection_args} -d :database -c :sql -A -R ',' -t",
171
- environment: psql_env
170
+ "#{dumper_connection_args} -d :database -c :sql -A -R ',' -t",
171
+ environment: dumper_psql_env
172
172
  )
173
173
 
174
174
  sequences = cmd.run(
@@ -1,3 +1,3 @@
1
1
  module DataKeeper
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_keeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roger Campos
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-14 00:00:00.000000000 Z
11
+ date: 2022-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord