scalingo_databases_rake_tasks 0.1.1 → 0.1.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fef412338d874cf4bc5f097a9d3a95b904308211
|
4
|
+
data.tar.gz: 5588bdef817f1dc48de78b3d445a8b558eb8b446
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f9d42eedb22b09311d12e7a9ab654051df1b3047e383ada1d760cc14d77347a1a382e85a6c354f73385e2d4579a6a88ed8a2f916b7811eca1be4465a6ba6bfd
|
7
|
+
data.tar.gz: 1bbab205f75415dbb7d13a8dfb567b182288b9138cfb10ae5a1217283c1215e53db4e6538f865a1cb3650592d52e98f228ca694fea8772b5d0543b7da31b5107
|
@@ -24,7 +24,7 @@ namespace :scalingo do
|
|
24
24
|
output = `scalingo -a #{app} env | grep "^#{variable}=" | cut -d '=' -f2 | tr -d '\n'`
|
25
25
|
uri = URI(output.strip)
|
26
26
|
if uri.to_s.blank?
|
27
|
-
raise VariableError
|
27
|
+
raise VariableError, "Environment variable #{variable} not found."
|
28
28
|
else
|
29
29
|
[uri.path[1..-1], uri.user, uri.password]
|
30
30
|
end
|
@@ -70,10 +70,10 @@ namespace :scalingo do
|
|
70
70
|
app = ENV["APP"]
|
71
71
|
variable = ENV["DB_ENV_NAME"] || default_env_name
|
72
72
|
unless app
|
73
|
-
abort
|
73
|
+
abort "Environment variable APP not found."
|
74
74
|
end
|
75
75
|
unless variable
|
76
|
-
abort
|
76
|
+
abort "Environment variable DB_ENV_NAME not found."
|
77
77
|
end
|
78
78
|
|
79
79
|
database, user, password = remote_credentials(app, variable)
|
@@ -77,13 +77,21 @@ namespace :scalingo do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
base_cmd = "tar xvzOf #{archive_name DUMP_NAME} | "
|
80
|
-
pg_cmd = "pg_restore -O -n public --clean
|
80
|
+
pg_cmd = "pg_restore -O -n public --clean"
|
81
|
+
pg_cmd << " --if-exists" if pg_restore_after_9_4
|
82
|
+
pg_cmd << " #{user_cmd} -h #{host} -p #{port} -d #{database}"
|
81
83
|
output = "#{base_cmd} PGPASSWORD=[FILTERED] #{pg_cmd}"
|
82
84
|
cmd = "#{base_cmd} #{password_cmd} #{pg_cmd}"
|
83
85
|
|
84
86
|
puts "*** Executing #{output}"
|
85
87
|
system(cmd)
|
86
88
|
end
|
89
|
+
|
90
|
+
def pg_restore_after_9_4?
|
91
|
+
version = `pg_restore --version`.split.last
|
92
|
+
major, minor = version.split('.')
|
93
|
+
major.to_i >= 9 && minor.to_i >= 4
|
94
|
+
end
|
87
95
|
end
|
88
96
|
|
89
97
|
end
|