Class: GTA::HerokuDB
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#database_yml_path ⇒ Object
readonly
Returns the value of attribute database_yml_path.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Instance Method Summary collapse
- #app_signature ⇒ Object
- #backup ⇒ Object
- #fetch ⇒ Object
- #file_name ⇒ Object
-
#initialize(app, env) ⇒ HerokuDB
constructor
A new instance of HerokuDB.
- #restore_from(url) ⇒ Object
- #url ⇒ Object
Methods included from Sh
Constructor Details
#initialize(app, env) ⇒ HerokuDB
Returns a new instance of HerokuDB.
7 8 9 10 |
# File 'lib/gta/heroku_db.rb', line 7 def initialize(app, env) @env = env @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
5 6 7 |
# File 'lib/gta/heroku_db.rb', line 5 def app @app end |
#database_yml_path ⇒ Object (readonly)
Returns the value of attribute database_yml_path.
5 6 7 |
# File 'lib/gta/heroku_db.rb', line 5 def database_yml_path @database_yml_path end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
5 6 7 |
# File 'lib/gta/heroku_db.rb', line 5 def env @env end |
Instance Method Details
#app_signature ⇒ Object
32 33 34 |
# File 'lib/gta/heroku_db.rb', line 32 def app_signature "#{app}-#{env}" end |
#backup ⇒ Object
16 17 18 |
# File 'lib/gta/heroku_db.rb', line 16 def backup sh("heroku pgbackups:capture --expire --app #{app_signature}") end |
#fetch ⇒ Object
24 25 26 |
# File 'lib/gta/heroku_db.rb', line 24 def fetch sh!("curl -o #{file_name} \"#{url}\"") end |
#file_name ⇒ Object
28 29 30 |
# File 'lib/gta/heroku_db.rb', line 28 def file_name "~/Downloads/#{app_signature}.sql" end |
#restore_from(url) ⇒ Object
20 21 22 |
# File 'lib/gta/heroku_db.rb', line 20 def restore_from(url) sh!("heroku pgbackups:restore DATABASE_URL \"#{url}\" --app #{app_signature} --confirm #{app_signature}") end |
#url ⇒ Object
12 13 14 |
# File 'lib/gta/heroku_db.rb', line 12 def url sh!("heroku pgbackups:url --app #{app_signature}").strip end |