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: 9375caa0de1e6e6f5f2a7c0c2ac4d0a5a09a6357
4
- data.tar.gz: 6dc2b750f6ddb3c52d8af993eb71c3aa57cfc12d
3
+ metadata.gz: fef412338d874cf4bc5f097a9d3a95b904308211
4
+ data.tar.gz: 5588bdef817f1dc48de78b3d445a8b558eb8b446
5
5
  SHA512:
6
- metadata.gz: 4eabd1086dffe6a0afe83076e204debf67af3d2ed3e410dbc6d790ffc41345ec6765f996660d18b89d3ac350f89036355476f149aa61c36b39b0890531bd6787
7
- data.tar.gz: f6b6d9ac88615b1a2130b5221a7a15c21f0dcf5bd1289e6e908c1975fda66891f437a5160aea337bdc66d4873d46a82c5d664d9874df0440001dffbd85521910
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 'ENV["APP"] missing.'
73
+ abort "Environment variable APP not found."
74
74
  end
75
75
  unless variable
76
- abort 'ENV["DB_ENV_NAME"] missing.'
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 --if-exists #{user_cmd} -h #{host} -p #{port} -d #{database}"
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
@@ -1,3 +1,3 @@
1
1
  module ScalingoDbTasks
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scalingo_databases_rake_tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scalingo