Module: DataMapper::Migrations::MysqlAdapter

Includes:
SQL
Defined in:
lib/dm-core/migrations.rb

Overview

module DataObjectsAdapter

Defined Under Namespace

Modules: ClassMethods, SQL

Constant Summary collapse

DEFAULT_ENGINE =
'InnoDB'.freeze
DEFAULT_CHARACTER_SET =
'utf8'.freeze
DEFAULT_COLLATION =
'utf8_unicode_ci'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SQL

#character_set, #collation, #create_table_statement, #property_schema_hash, #property_schema_statement, #schema_name, #show_variable, #supports_drop_table_if_exists?, #supports_serial?

Class Method Details

.included(base) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

TODO: document



325
326
327
# File 'lib/dm-core/migrations.rb', line 325

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#field_exists?(storage_name, field) ⇒ Boolean

TODO: document

Returns:

  • (Boolean)


337
338
339
340
# File 'lib/dm-core/migrations.rb', line 337

def field_exists?(storage_name, field)
  result = query("SHOW COLUMNS FROM #{quote_name(storage_name)} LIKE ?", field).first
  result ? result.field == field : false
end

#storage_exists?(storage_name) ⇒ Boolean

TODO: document

Returns:

  • (Boolean)


331
332
333
# File 'lib/dm-core/migrations.rb', line 331

def storage_exists?(storage_name)
  query('SHOW TABLES LIKE ?', storage_name).first == storage_name
end