Sha256: fc52f7024994333efd2767f5d58c79f83fdb23c8b25eeeb5b6035bfd123b88a7
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
require_relative 'utilities' module Ferry class Dumper < Utilities def dump(environment) @dbadapter = db_connect(environment) @dbenv = environment @dbname = YAML::load(IO.read("config/database.yml"))[@dbenv]["database"] @outfile_path = "db/sql_dumps/#{@dbname}/#{@dbadapter}/#{@dbenv}/dumpfile.sql" @commands = { "sqlite3" => "sqlite3 db/#{@dbenv}.sqlite3 .dump > #{@outfile_path}", "postgresql" => "pg_dump #{@dbname} > #{@outfile_path}", "mysql2" => "mysqldump #{@dbname} > #{@outfile_path}" } if check_valid_db(@dbadapter) create_dirs execute(@commands[@dbadapter]) else raise "Dump failed: #{@dbadapter} is not supported by ferry at this time" return false end end def create_dirs homedir = "db/sql_dumps/#{@dbname}/#{@dbadapter}/#{@dbenv}" FileUtils.mkpath homedir unless Dir[homedir].present? FileUtils.touch(@outfile_path) unless File.exist?(@outfile_path) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ferry-2.0.0 | lib/ferry/dumper.rb |
ferry-1.3.3 | lib/ferry/dumper.rb |