class ActiveRecord::Snapshot::MySQL
Public Class Methods
dump(*args)
click to toggle source
# File lib/active_record/snapshot/commands/mysql.rb, line 6 def self.dump(*args) new.dump(*args) end
import(*args)
click to toggle source
# File lib/active_record/snapshot/commands/mysql.rb, line 15 def self.import(*args) new.import(*args) end
Public Instance Methods
dump(tables:, output:)
click to toggle source
# File lib/active_record/snapshot/commands/mysql.rb, line 10 def dump(tables:, output:) dump_command("--no-data #{database} > #{output}") && dump_command("--quick #{database} #{tables.join(" ")} >> #{output}") end
import(input:)
click to toggle source
# File lib/active_record/snapshot/commands/mysql.rb, line 19 def import(input:) system(<<~SH) nice mysql \\ --user=#{username} \\ #{password_string} \\ --host=#{host} \\ #{database} < #{input} SH end
Private Instance Methods
database()
click to toggle source
# File lib/active_record/snapshot/commands/mysql.rb, line 52 def database escape(db_config.database) end
db_config()
click to toggle source
# File lib/active_record/snapshot/commands/mysql.rb, line 31 def db_config ActiveRecord::Snapshot.config.db end
dump_command(args = "")
click to toggle source
# File lib/active_record/snapshot/commands/mysql.rb, line 56 def dump_command(args = "") system(<<~SH) nice mysqldump \\ --user=#{username} \\ #{password_string} \\ --host=#{host} \\ #{args} SH end
escape(value)
click to toggle source
# File lib/active_record/snapshot/commands/mysql.rb, line 35 def escape(value) Shellwords.escape(value) end
host()
click to toggle source
# File lib/active_record/snapshot/commands/mysql.rb, line 48 def host escape(db_config.host) end
password_string()
click to toggle source
# File lib/active_record/snapshot/commands/mysql.rb, line 43 def password_string return if db_config.password.blank? "--password=#{escape(db_config.password)}" end
username()
click to toggle source
# File lib/active_record/snapshot/commands/mysql.rb, line 39 def username escape(db_config.username) end