capistrano3-postgres 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -4
- data/lib/capistrano3/postgres/version.rb +1 -1
- data/lib/capistrano3/tasks/postgres.rb +9 -8
- 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: 7b52e13dd8550f0e2ee5e6e2e5ae7e1c32696011
|
4
|
+
data.tar.gz: 71e79f4fb7a52c8b9c4636312e68f11853ecc1fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
```
|
@@ -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
|
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
|
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.
|
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:
|
11
|
+
date: 2015-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|