Class: SequelRails::Storage::Mysql

Inherits:
Abstract
  • Object
show all
Defined in:
lib/sequel_rails/storage/mysql.rb

Direct Known Subclasses

Mysql2

Instance Attribute Summary

Attributes inherited from Abstract

#config

Instance Method Summary collapse

Methods inherited from Abstract

#charset, #close_connections, #create, #database, #drop, #dump, #host, #initialize, #load, #owner, #password, #port, #schema_information_dump, #search_path, #username

Constructor Details

This class inherits a constructor from SequelRails::Storage::Abstract

Instance Method Details

#_createObject



4
5
6
# File 'lib/sequel_rails/storage/mysql.rb', line 4

def _create
  execute "CREATE DATABASE IF NOT EXISTS `#{database}` DEFAULT CHARACTER SET #{charset} DEFAULT COLLATE #{collation}"
end

#_dropObject



8
9
10
# File 'lib/sequel_rails/storage/mysql.rb', line 8

def _drop
  execute "DROP DATABASE IF EXISTS `#{database}`"
end

#_dump(filename) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/sequel_rails/storage/mysql.rb', line 12

def _dump(filename)
  commands = ['mysqldump']
  add_connection_settings commands
  add_flag commands, '--no-data'
  add_flag commands, '--skip-dump-date'
  add_option commands, '--result-file', filename
  commands << database
  safe_exec commands
end

#_load(filename) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/sequel_rails/storage/mysql.rb', line 22

def _load(filename)
  commands = ['mysql']
  add_connection_settings commands
  add_option commands, '--database', database
  add_option commands, '--execute', %(SET FOREIGN_KEY_CHECKS = 0; SOURCE #{filename}; SET FOREIGN_KEY_CHECKS = 1)
  safe_exec commands
end

#collationObject



30
31
32
# File 'lib/sequel_rails/storage/mysql.rb', line 30

def collation
  @collation ||= super || 'utf8_unicode_ci'
end