capistrano3-postgres 0.2.4 → 0.2.5

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
- SHA1:
3
- metadata.gz: 4e80a92bd0f933cc263c8a2147450b111c4aa47d
4
- data.tar.gz: bc269fdedb5ae903c724e822dab203bdf52850bc
2
+ SHA256:
3
+ metadata.gz: b432337df094358906c4d46a45c6365d820accfd62dd6c0a085a95ebc905014d
4
+ data.tar.gz: db1306a7b51ac53b30c5efbe999bf2d81873dc990baaf329fddc1d77fd2c1b81
5
5
  SHA512:
6
- metadata.gz: 1d2556abe85c3a4f1d0391aa672654e258ee6464b882c462c002d975673c588e46fb5f9008f73e6d3a233a36ed1a2824c91448b4f232e47e3debb637ae78bfd9
7
- data.tar.gz: 14377d6bc96bae2775703a212d1e6bf45a95e3bf337c7ac54ac1efba437313f906de852c473759eefdaf40660bac976bda41184a51bcf80ea8c9d47d5b850da0
6
+ metadata.gz: e64ad68263d7047df31f05ebf8c75ef1b0b3abcd4d4dc3e7b5a02c90adb66b8a237339d551993d5abc14b35242a616dcfd243db1f668cd2454854a7d7bb09ea8
7
+ data.tar.gz: f879125f07576d98beb42250b842cd1329f4d1319f5d958b52586a086d605158163c5e28eb8af868a18a7ba49a4731fb03c35910bcd0fd4685b4f1a25a86adfd
data/README.md CHANGED
@@ -74,6 +74,12 @@ If you need only specific tables to be dumped:
74
74
  set :postgres_backup_table, -> { ['users', 'orders'] }
75
75
  ```
76
76
 
77
+ If you need to support rails 6+ multiple database support, please set database_name to use:
78
+
79
+ ```
80
+ set :postgres_database, 'primary'
81
+ ```
82
+
77
83
  ## Contributing
78
84
 
79
85
  1. Fork it ( http://github.com/spilin/capistrano3-postgres/fork )
@@ -1,5 +1,5 @@
1
1
  module Capistrano3
2
2
  module Postgres
3
- VERSION = "0.2.4"
3
+ VERSION = "0.2.5"
4
4
  end
5
5
  end
@@ -12,6 +12,7 @@ namespace :load do
12
12
  set :postgres_backup_exclude_table_data, -> { [] }
13
13
  set :postgres_backup_exclude_table, -> { [] }
14
14
  set :postgres_backup_table, -> { [] }
15
+ set :postgres_database, -> { nil }
15
16
  end
16
17
  end
17
18
 
@@ -120,8 +121,7 @@ namespace :postgres do
120
121
  desc 'Replicate database locally'
121
122
  task :replicate do
122
123
  grab_local_database_config
123
- config = fetch(:postgres_local_database_config)
124
- ask(:database_name, config['database'])
124
+ ask(:database_name, fetch(:postgres_local_database_config)['database'])
125
125
  invoke "postgres:backup:create"
126
126
  invoke "postgres:backup:download"
127
127
  invoke "postgres:backup:import"
@@ -144,7 +144,7 @@ namespace :postgres do
144
144
  env = 'development'
145
145
  preload_env_variables(env)
146
146
  yaml_content = ERB.new(capture 'cat config/database.yml').result
147
- set :postgres_local_database_config, database_config_defaults.merge(YAML::load(yaml_content)[env])
147
+ set_postgres_database_config(yaml_content, env, :postgres_local_database_config)
148
148
  end
149
149
  end
150
150
  end
@@ -164,7 +164,7 @@ namespace :postgres do
164
164
 
165
165
  capture_config_cmd = "ruby -e \"#{eval_yaml_with_erb}\""
166
166
  yaml_content = test('ruby -v') ? capture(capture_config_cmd) : capture(:bundle, :exec, capture_config_cmd)
167
- set :postgres_remote_database_config, database_config_defaults.merge(YAML::load(yaml_content)[env])
167
+ set_postgres_database_config(yaml_content, env, :postgres_remote_database_config)
168
168
  end
169
169
  end
170
170
  end
@@ -173,6 +173,12 @@ namespace :postgres do
173
173
  { 'host' => 'localhost' }
174
174
  end
175
175
 
176
+ def set_postgres_database_config(yaml_content, env, key)
177
+ database_config = YAML::load(yaml_content)[env]
178
+ database_config = database_config[fetch(:postgres_database)] if fetch(:postgres_database)
179
+ set key, database_config_defaults.merge(database_config)
180
+ end
181
+
176
182
  # Load environment variables for configurations.
177
183
  # Useful for such gems as Dotenv, Figaro, etc.
178
184
  def preload_env_variables(env)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano3-postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Krasynskyi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-13 00:00:00.000000000 Z
11
+ date: 2020-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -60,8 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  requirements: []
63
- rubyforge_project:
64
- rubygems_version: 2.4.5.1
63
+ rubygems_version: 3.0.6
65
64
  signing_key:
66
65
  specification_version: 4
67
66
  summary: Create, download and restore postgres database.