Class: Brillo::Adapter::MySQL

Inherits:
Base
  • Object
show all
Defined in:
lib/brillo/adapter/mysql.rb

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from Base

#initialize, #recreate_db, #table_footer

Methods included from Logger

#logger, logger, logger=

Constructor Details

This class inherits a constructor from Brillo::Adapter::Base

Instance Method Details

#dump_structure_and_migrations(config) ⇒ Object



23
24
25
# File 'lib/brillo/adapter/mysql.rb', line 23

def dump_structure_and_migrations(config)
  Dumper::MysqlDumper.new(config).dump
end


14
15
16
17
18
19
20
21
# File 'lib/brillo/adapter/mysql.rb', line 14

def footer
  super + <<-SQL
  SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  SET AUTOCOMMIT = @OLD_AUTOCOMMIT;
  COMMIT;
  SQL
end

#headerObject



4
5
6
7
8
9
10
11
12
# File 'lib/brillo/adapter/mysql.rb', line 4

def header
  super + <<-SQL
  -- Disable autocommit, uniquechecks, and foreign key checks, for performance on InnoDB
  -- http://dev.mysql.com/doc/refman/5.5/en/optimizing-innodb-bulk-data-loading.html
  SET @OLD_AUTOCOMMIT=@@AUTOCOMMIT, AUTOCOMMIT = 0;
  SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS = 0;
  SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS = 0;
  SQL
end

#load_commandObject



27
28
29
30
31
# File 'lib/brillo/adapter/mysql.rb', line 27

def load_command
  host = config["host"] ? "--host #{config["host"]}" : ""
  password = config["password"] ? "-p#{config["password"]}" : ""
  "mysql #{host} -u #{config.fetch("username")} #{password} #{config.fetch("database")}"
end