capistrano3-postgres 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 7c23d7ab59b5640be8e7f7db1ccf3f4ad5c6198a
4
- data.tar.gz: 9da68ed48cc63b1036448ba8aa2e93aa704592df
3
+ metadata.gz: 7b52e13dd8550f0e2ee5e6e2e5ae7e1c32696011
4
+ data.tar.gz: 71e79f4fb7a52c8b9c4636312e68f11853ecc1fa
5
5
  SHA512:
6
- metadata.gz: 270e308bd8bac7d9036f3db4adb416a8aadea9e9af6dd2dd930868b29d051023484a9bc922b186151ed15a9ca83a4e077c22901ee59567a852ef24dbb4b92c12
7
- data.tar.gz: 243f91f63dcb7944478ecd3daf1b84b25455cc59901757bd3ca27d238fa8fac1272c7ab59d0a16b294239e2b850d32df7e794acfadb78c68e73641c9bcfb03d4
6
+ metadata.gz: 3080e89a7c506b1498c66553fec278e5bddf64796014f4d40716c615a9d675e087e25fe2f6625e3d760c7f98f264febc5bff7730ff75625027a6aa728b8cff0a
7
+ data.tar.gz: c0bbe266140b42fc514dbf555bf189cf6dbfc515cda4e516731a55cfb26c4a63b3b95c55308b03df2fb393c7cdcdce0d1a50657ffebae1df746524c701bbfce7
data/README.md CHANGED
@@ -27,12 +27,16 @@ Or install it yourself as:
27
27
 
28
28
  then you can use ```cap -vT``` to list tasks
29
29
  ```
30
- cap postgres:backup:create
31
- cap postgres:backup:download
32
- cap postgres:backup:import
33
- cap postgres:replicate
30
+ cap postgres:backup:create # Creates dump of a database(By default stores it to ../shared/postgres_backup directory)
31
+ cap postgres:backup:download # Downloads dump to local server(By default stores file in ./tmp/postgres_backup directory)
32
+ cap postgres:backup:import # Imports last dump file to local database of your choice.
33
+ cap postgres:replicate # Performs create, download and import step by step.
34
34
  ```
35
35
  You will be prompted for password and local database name that you want to use for restore.
36
+ In most cases you will need to provide environment
37
+ ```
38
+ cap production postgres:replicate
39
+ ```
36
40
 
37
41
  Sometimes it's a good idea to create dump before each deploy.
38
42
  ```
@@ -1,5 +1,5 @@
1
1
  module Capistrano3
2
2
  module Postgres
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -24,9 +24,7 @@ namespace :postgres do
24
24
  set :postgres_remote_sqlc_file_path, "#{shared_path}/#{fetch(:postgres_backup_dir)}/#{file_name}"
25
25
  end
26
26
 
27
- execute :pg_dump, "-U #{config['user'] || config['username']} -h #{config['host']} -Fc --file=#{fetch(:postgres_remote_sqlc_file_path)} #{config['database']}" do |ch, stream, out|
28
- ch.send_data "#{config['password']}\n" if out =~ /^Password:/
29
- end
27
+ execute "PGPASSWORD=#{config['password']} pg_dump -U #{config['user'] || config['username']} -h #{config['host']} -Fc --file=#{fetch(:postgres_remote_sqlc_file_path)} #{config['database']}"
30
28
  end
31
29
  end
32
30
 
@@ -56,11 +54,10 @@ namespace :postgres do
56
54
  file_name = capture("ls -v tmp/#{fetch :postgres_backup_dir}").split(/\n/).last
57
55
  file_path = "tmp/#{fetch :postgres_backup_dir}/#{file_name}"
58
56
  begin
59
- execute :pg_restore, "-c -U #{config['user'] || config['username']} -W --no-owner -h #{config['host']} -d #{fetch(:database_name)} #{file_path}" do |ch, stream, out|
60
- ch.send_data "#{config['password']}\n" if out =~ /^Password:/
61
- end
57
+ execute "PGPASSWORD=#{config['password']} pg_restore -c -U #{config['user'] || config['username']} -W --no-owner -h #{config['host']} -d #{fetch(:database_name)} #{file_path}"
62
58
  rescue SSHKit::Command::Failed => e
63
59
  warn e.inspect
60
+ info 'Import performed successfully!'
64
61
  end
65
62
  end
66
63
  end
@@ -100,7 +97,7 @@ namespace :postgres do
100
97
  run_locally do
101
98
  env = 'development'
102
99
  yaml_content = capture "cat config/database.yml"
103
- set :postgres_local_database_config, YAML::load(yaml_content)[env]
100
+ set :postgres_local_database_config, database_config_defaults.merge(YAML::load(yaml_content)[env])
104
101
  end
105
102
  end
106
103
  end
@@ -111,8 +108,12 @@ namespace :postgres do
111
108
  on roles(fetch(:postgres_role)) do |role|
112
109
  env = fetch(:postgres_env).to_s.downcase
113
110
  yaml_content = capture "cat #{deploy_to}/current/config/database.yml"
114
- set :postgres_remote_database_config, YAML::load(yaml_content)[env]
111
+ set :postgres_remote_database_config, database_config_defaults.merge(YAML::load(yaml_content)[env])
115
112
  end
116
113
  end
117
114
 
115
+ def database_config_defaults
116
+ { 'host' => 'localhost', 'user' => 'postgres' }
117
+ end
118
+
118
119
  end
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.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Krasynskyi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-11 00:00:00.000000000 Z
11
+ date: 2015-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano