Class: Brillo::Loader
- Inherits:
-
Object
- Object
- Brillo::Loader
- Includes:
- Helpers::ExecHelper, Logger
- Defined in:
- lib/brillo/loader.rb
Overview
Responsible for fetching an existing SQL scrub from S3, cleaning the database, and loading the SQL.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #import_sql ⇒ Object
-
#initialize(config) ⇒ Loader
constructor
A new instance of Loader.
- #load! ⇒ Object
- #recreate_db ⇒ Object
Methods included from Logger
Methods included from Helpers::ExecHelper
Constructor Details
#initialize(config) ⇒ Loader
Returns a new instance of Loader.
9 10 11 12 |
# File 'lib/brillo/loader.rb', line 9 def initialize(config) raise "⚠️ DON'T LOAD IN PRODUCTION! ⚠️" if production? @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/brillo/loader.rb', line 7 def config @config end |
Instance Method Details
#import_sql ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/brillo/loader.rb', line 24 def import_sql if config.compress execute!("gunzip -c #{config.compressed_dump_path} | #{sql_load_command}") else execute!("cat #{config.dump_path} | #{sql_load_command}") end logger.info "Import complete!" end |
#load! ⇒ Object
14 15 16 17 18 |
# File 'lib/brillo/loader.rb', line 14 def load! config.transferrer.download recreate_db import_sql end |
#recreate_db ⇒ Object
20 21 22 |
# File 'lib/brillo/loader.rb', line 20 def recreate_db config.adapter.recreate_db end |