Class: ActiveRecord::Snapshot::MySQL

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/snapshot/commands/mysql.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.dump(*args) ⇒ Object



6
7
8
# File 'lib/active_record/snapshot/commands/mysql.rb', line 6

def self.dump(*args)
  new.dump(*args)
end

.import(*args) ⇒ Object



15
16
17
# File 'lib/active_record/snapshot/commands/mysql.rb', line 15

def self.import(*args)
  new.import(*args)
end

Instance Method Details

#dump(tables:, output:) ⇒ Object



10
11
12
13
# File 'lib/active_record/snapshot/commands/mysql.rb', line 10

def dump(tables:, output:)
  dump_command("--no-data --set-gtid-purged=OFF #{database} > #{output}") &&
    dump_command("--quick --set-gtid-purged=OFF #{database} #{tables.join(" ")} >> #{output}")
end

#import(input:) ⇒ Object



19
20
21
22
23
24
25
26
27
# 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