class Brillo::Loader
Responsible for fetching an existing SQL scrub from S3, cleaning the database, and loading the SQL.
Attributes
config[R]
Public Class Methods
new(config)
click to toggle source
# File lib/brillo/loader.rb, line 9 def initialize(config) raise "⚠️ DON'T LOAD IN PRODUCTION! ⚠️" if production? @config = config end
Public Instance Methods
download_sql(keep_local)
click to toggle source
# File lib/brillo/loader.rb, line 20 def download_sql(keep_local) if keep_local path = config.compress ? config.compressed_dump_path : config.dump_path return if File.exists? path end config.transferrer.download end
import_sql()
click to toggle source
# File lib/brillo/loader.rb, line 34 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!(keep_local)
click to toggle source
# File lib/brillo/loader.rb, line 14 def load!(keep_local) download_sql(keep_local) recreate_db import_sql end
recreate_db()
click to toggle source
# File lib/brillo/loader.rb, line 29 def recreate_db return unless config.recreate_db config.adapter.recreate_db end
Private Instance Methods
production?()
click to toggle source
# File lib/brillo/loader.rb, line 45 def production? (ENV['RAILS_ENV'] || ENV['RUBY_ENV']) == 'production' end
sql_load_command()
click to toggle source
# File lib/brillo/loader.rb, line 49 def sql_load_command config.adapter.load_command end