Class: Naifa::Heroku::Postgres
- Inherits:
-
Object
- Object
- Naifa::Heroku::Postgres
- Defined in:
- lib/naifa/heroku.rb
Class Method Summary collapse
- .backup(filename, environment = :staging) ⇒ Object
- .build_restore_command(backup_url, environment) ⇒ Object
- .capture(environment = :staging) ⇒ Object
- .restore(environment = :staging) ⇒ Object
- .sync(from = :production, to = :staging) ⇒ Object
Class Method Details
.backup(filename, environment = :staging) ⇒ Object
6 7 8 9 |
# File 'lib/naifa/heroku.rb', line 6 def self.backup(filename, environment=:staging) res = capture(environment) Utils.download_file(filename, "`#{build_public_url_command(environment)}`") if res end |
.build_restore_command(backup_url, environment) ⇒ Object
24 25 26 |
# File 'lib/naifa/heroku.rb', line 24 def self.build_restore_command(backup_url, environment) "heroku pg:backups:restore #{backup_url} DATABASE_URL -r #{environment}" end |
.capture(environment = :staging) ⇒ Object
16 17 18 |
# File 'lib/naifa/heroku.rb', line 16 def self.capture(environment=:staging) Kernel.system(build_capture_command(environment)) end |
.restore(environment = :staging) ⇒ Object
20 21 22 |
# File 'lib/naifa/heroku.rb', line 20 def self.restore(environment=:staging) Kernel.system(build_capture_command(environment)) end |
.sync(from = :production, to = :staging) ⇒ Object
11 12 13 14 |
# File 'lib/naifa/heroku.rb', line 11 def self.sync(from=:production, to=:staging) res = capture(from) Kernel.system(build_restore_command("`#{build_public_url_command(from)}`", to)) if res end |