Module: DataMapper::Migrations::MysqlAdapter

Includes:
DataObjectsAdapter, SQL
Defined in:
lib/dm-migrations/adapters/dm-mysql-adapter.rb

Defined Under Namespace

Modules: ClassMethods, SQL

Constant Summary collapse

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

Instance Attribute Summary

Attributes included from SQL

#storage_engine

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?

Methods included from DataObjectsAdapter

#create_model_storage, #destroy_model_storage, #upgrade_model_storage

Methods included from DataObjectsAdapter::SQL

#add_column_statement, #alter_table_add_column_statement, #create_index_statement, #create_index_statements, #create_table_statement, #create_unique_index_statements, #drop_table_statement, #indexes, #property_schema_hash, #property_schema_statement, #schema_name, #supports_drop_table_if_exists?, #supports_serial?, #unique_indexes

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.



15
16
17
18
# File 'lib/dm-migrations/adapters/dm-mysql-adapter.rb', line 15

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

Instance Method Details

#field_exists?(storage_name, field) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
# File 'lib/dm-migrations/adapters/dm-mysql-adapter.rb', line 26

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

#storage_exists?(storage_name) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/dm-migrations/adapters/dm-mysql-adapter.rb', line 21

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