Class: Swift::Adapter::Mysql

Inherits:
Sql show all
Defined in:
lib/swift/adapter/mysql.rb

Direct Known Subclasses

Eventmachine::Mysql, Synchrony::Mysql

Constant Summary

Constants inherited from Swift::Adapter

EM

Instance Attribute Summary

Attributes inherited from Swift::Adapter

#db

Instance Method Summary collapse

Methods inherited from Sql

#fields, #transaction

Methods included from Migrations::InstanceMethods

#migrate!

Methods inherited from Swift::Adapter

#create, #delete, #execute, #get, #identity_map, #log_command, #prepare, #trace, #trace?, #update

Constructor Details

#initialize(options = {}) ⇒ Mysql


7
8
9
# File 'lib/swift/adapter/mysql.rb', line 7

def initialize options = {}
  super Swift::DB::Mysql.new(options)
end

Instance Method Details

#field_type(attribute) ⇒ Object

TODO Swift::Type::Bignum ? serial is an alias for bigint in mysql, we want integer type to be migrated as integer type in the database (not bigint or smallint or shortint or whatever).


18
19
20
21
22
23
# File 'lib/swift/adapter/mysql.rb', line 18

def field_type attribute
  case attribute
    when Type::Integer then attribute.serial ? 'integer auto_increment' : 'integer'
    else super
  end
end

#returning?Boolean


11
12
13
# File 'lib/swift/adapter/mysql.rb', line 11

def returning?
  false
end

#tablesObject


25
26
27
# File 'lib/swift/adapter/mysql.rb', line 25

def tables
  execute("show tables").map(&:values).flatten
end