class DBFork
Attributes
commands[RW]
Public Class Methods
new(root_dir, connection, env, branch_name, logger)
click to toggle source
# File lib/database_fork/db_fork.rb, line 35 def initialize(root_dir, connection, env, branch_name, logger) @root_dir = root_dir @connection = connection @env = env @branch_name = branch_name @logger = logger @character_set = nil @collation = nil reset_commands! end
Public Instance Methods
character_set()
click to toggle source
# File lib/database_fork/db_fork.rb, line 90 def character_set @character_set || 'utf8' end
collation()
click to toggle source
# File lib/database_fork/db_fork.rb, line 94 def collation @collation || 'utf8_unicode_ci' end
connection_parameters()
click to toggle source
implement this is your adapter:
# File lib/database_fork/db_fork.rb, line 14 def connection_parameters raise NotImplementedError end
create_database()
click to toggle source
# File lib/database_fork/db_fork.rb, line 22 def create_database raise NotImplementedError end
create_dump()
click to toggle source
# File lib/database_fork/db_fork.rb, line 18 def create_dump raise NotImplementedError end
delete_dump_file()
click to toggle source
# File lib/database_fork/db_fork.rb, line 86 def delete_dump_file record_command "rm #{dump_file}", 'cleanup' end
dump_file()
click to toggle source
# File lib/database_fork/db_fork.rb, line 98 def dump_file File.join(@root_dir, 'tmp', "dump_#{source_db}.sql") end
exists?(dry_run = false)
click to toggle source
implement this is your adapter:
# File lib/database_fork/db_fork.rb, line 9 def exists?(dry_run = false) raise NotImplementedError end
export_env(dry_run = false)
click to toggle source
# File lib/database_fork/db_fork.rb, line 79 def export_env(dry_run = false) reset_commands! filename = File.join(@root_dir, 'tmp', "DATABASE_FORK_#{@env.upcase}") record_command "echo #{target_name} > #{filename}", "setting DATABASE_FORK_#{@env.upcase}" execute_commands unless dry_run end
fork(dry_run = false)
click to toggle source
# File lib/database_fork/db_fork.rb, line 50 def fork(dry_run = false) reset_commands! log_info "creating database fork '#{target_name}' from #{source_db}" create_dump create_database import_dump delete_dump_file execute_commands unless dry_run end
import_dump()
click to toggle source
# File lib/database_fork/db_fork.rb, line 26 def import_dump raise NotImplementedError end
query_default_settings(dry_run = false)
click to toggle source
# File lib/database_fork/db_fork.rb, line 30 def query_default_settings(dry_run = false) raise NotImplementedError end
reset_env(dry_run = false)
click to toggle source
# File lib/database_fork/db_fork.rb, line 72 def reset_env(dry_run = false) reset_commands! filename = File.join(@root_dir, 'tmp', "DATABASE_FORK_#{@env.upcase}") record_command "rm #{filename}", "removing DATABASE_FORK_#{@env.upcase}" execute_commands unless dry_run end
source_db()
click to toggle source
# File lib/database_fork/db_fork.rb, line 68 def source_db @connection['database'] end
target_name()
click to toggle source
# File lib/database_fork/db_fork.rb, line 63 def target_name "#{source_db}_#{@branch_name}" end