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 +4 -4
- data/lib/capistrano3/postgres/version.rb +1 -1
- data/lib/capistrano3/tasks/postgres.rb +7 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7a08e03347397dea2b027afa75fac9929f82184
|
4
|
+
data.tar.gz: 7c3b1d8765ea24754701b0e31951d4f30a7531cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8527c0f1c0a9a97195909d7c095a267c0508a43bca5615098d1c3aa238e3c518feb9692e7771d6d103bf522b9e80260fe91f1bac26b3ed16b26f58e1c7611e66
|
7
|
+
data.tar.gz: 703183c9f4a37a4632aa9e960988cd110a13a515b4dd8929f9a837080a7e24bd09a3b806620ccfac47f67de60db14b7b49a72bd67ca053feacd5729e62db6de0
|
@@ -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, :
|
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
|
-
|
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.
|
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-
|
11
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|