capistrano3-postgres 0.0.2 → 0.0.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
  SHA1:
3
- metadata.gz: 7b52e13dd8550f0e2ee5e6e2e5ae7e1c32696011
4
- data.tar.gz: 71e79f4fb7a52c8b9c4636312e68f11853ecc1fa
3
+ metadata.gz: f7a08e03347397dea2b027afa75fac9929f82184
4
+ data.tar.gz: 7c3b1d8765ea24754701b0e31951d4f30a7531cd
5
5
  SHA512:
6
- metadata.gz: 3080e89a7c506b1498c66553fec278e5bddf64796014f4d40716c615a9d675e087e25fe2f6625e3d760c7f98f264febc5bff7730ff75625027a6aa728b8cff0a
7
- data.tar.gz: c0bbe266140b42fc514dbf555bf189cf6dbfc515cda4e516731a55cfb26c4a63b3b95c55308b03df2fb393c7cdcdce0d1a50657ffebae1df746524c701bbfce7
6
+ metadata.gz: 8527c0f1c0a9a97195909d7c095a267c0508a43bca5615098d1c3aa238e3c518feb9692e7771d6d103bf522b9e80260fe91f1bac26b3ed16b26f58e1c7611e66
7
+ data.tar.gz: 703183c9f4a37a4632aa9e960988cd110a13a515b4dd8929f9a837080a7e24bd09a3b806620ccfac47f67de60db14b7b49a72bd67ca053feacd5729e62db6de0
@@ -1,5 +1,5 @@
1
1
  module Capistrano3
2
2
  module Postgres
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  namespace :load do
2
2
  task :defaults do
3
3
  set :postgres_backup_dir, -> { 'postgres_backup' }
4
- set :postgres_role, :app
4
+ set :postgres_role, :db
5
5
  set :postgres_env, -> { fetch(:rack_env, fetch(:rails_env, fetch(:stage))) }
6
6
  set :postgres_remote_sqlc_file_path, -> { nil }
7
7
  set :postgres_local_database_config, -> { nil }
@@ -15,8 +15,8 @@ namespace :postgres do
15
15
 
16
16
  desc 'Create database dump'
17
17
  task :create do
18
- grab_remote_database_config
19
18
  on roles(fetch(:postgres_role)) do |role|
19
+ grab_remote_database_config
20
20
  config = fetch(:postgres_remote_database_config)
21
21
 
22
22
  unless fetch(:postgres_remote_sqlc_file_path)
@@ -54,10 +54,14 @@ namespace :postgres do
54
54
  file_name = capture("ls -v tmp/#{fetch :postgres_backup_dir}").split(/\n/).last
55
55
  file_path = "tmp/#{fetch :postgres_backup_dir}/#{file_name}"
56
56
  begin
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}"
57
+ pgpass_path = File.join(Dir.pwd, '.pgpass')
58
+ File.open(pgpass_path, 'w+', 0600) { |file| file.write("*:*:*:#{config['user'] || config['username']}:#{config['password']}") }
59
+ execute "PGPASSFILE=#{pgpass_path} pg_restore -c -U #{config['user'] || config['username']} --no-owner -h #{config['host']} -d #{fetch(:database_name)} #{file_path}"
58
60
  rescue SSHKit::Command::Failed => e
59
61
  warn e.inspect
60
62
  info 'Import performed successfully!'
63
+ ensure
64
+ File.delete(pgpass_path) if File.exist?(pgpass_path)
61
65
  end
62
66
  end
63
67
  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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Krasynskyi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-07 00:00:00.000000000 Z
11
+ date: 2015-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano