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



19
20
21
# File 'lib/active_record/snapshot/commands/mysql.rb', line 19

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

Instance Method Details

#dump(tables:, output:) ⇒ Object



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

def dump(tables:, output:)
  # the --no-tablespaces flag are necessary to dump a db
  # containing SQL view queries and tablespace metadata
  dump_command("--no-data --single-transaction --no-tablespaces #{build_ignore_flags} #{database} > #{output}") &&
    dump_command(
      "--quick --single-transaction --no-tablespaces #{build_ignore_flags} #{database} #{tables.join(' ')} >> #{output}"
    )
end

#import(input:) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/active_record/snapshot/commands/mysql.rb', line 23

def import(input:)
  system("    nice mysql \\\\\n      --user=\#{username} \\\\\n      \#{password_string} \\\\\n      --host=\#{host} \\\\\n      \#{database} < \#{input}\n  SH\nend\n")