Module: DataMapper::Migrations::MysqlAdapter::SQL
- Included in:
- DataMapper::Migrations::MysqlAdapter
- Defined in:
- lib/dm-migrations/adapters/dm-mysql-adapter.rb
Overview
:nodoc:
Constant Summary collapse
- VALUE_METHOD =
private ## This cannot be private for current migrations
RUBY_PLATFORM[/java/] ? :variable_value : :value
Instance Method Summary collapse
- #character_set ⇒ Object private
- #collation ⇒ Object private
- #create_table_statement(connection, model, properties) ⇒ Object private
- #property_schema_hash(property) ⇒ Object private
- #property_schema_statement(connection, schema) ⇒ Object private
- #schema_name ⇒ Object private
- #show_variable(name) ⇒ Object private
- #supports_drop_table_if_exists? ⇒ Boolean private
- #supports_serial? ⇒ Boolean private
Instance Method Details
#character_set ⇒ 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.
88 89 90 |
# File 'lib/dm-migrations/adapters/dm-mysql-adapter.rb', line 88 def character_set @character_set ||= show_variable('character_set_connection') || DEFAULT_CHARACTER_SET end |
#collation ⇒ 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.
93 94 95 |
# File 'lib/dm-migrations/adapters/dm-mysql-adapter.rb', line 93 def collation @collation ||= show_variable('collation_connection') || DEFAULT_COLLATION end |
#create_table_statement(connection, model, properties) ⇒ 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.
53 54 55 |
# File 'lib/dm-migrations/adapters/dm-mysql-adapter.rb', line 53 def create_table_statement(connection, model, properties) "#{super} ENGINE = #{DEFAULT_ENGINE} CHARACTER SET #{character_set} COLLATE #{collation}" end |
#property_schema_hash(property) ⇒ 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.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/dm-migrations/adapters/dm-mysql-adapter.rb', line 58 def property_schema_hash(property) schema = super if property.kind_of?(Property::Text) schema[:primitive] = text_column_statement(property.length) schema.delete(:default) end if property.kind_of?(Property::Integer) min = property.min max = property.max schema[:primitive] = integer_column_statement(min..max) if min && max end schema end |
#property_schema_statement(connection, schema) ⇒ 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.
77 78 79 80 81 82 83 84 85 |
# File 'lib/dm-migrations/adapters/dm-mysql-adapter.rb', line 77 def property_schema_statement(connection, schema) statement = super if supports_serial? && schema[:serial] statement << ' AUTO_INCREMENT' end statement end |
#schema_name ⇒ 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.
47 48 49 50 |
# File 'lib/dm-migrations/adapters/dm-mysql-adapter.rb', line 47 def schema_name # TODO: is there a cleaner way to find out the current DB we are connected to? normalized_uri.path.split('/').last end |
#show_variable(name) ⇒ 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.
98 99 100 101 |
# File 'lib/dm-migrations/adapters/dm-mysql-adapter.rb', line 98 def show_variable(name) result = select('SHOW VARIABLES LIKE ?', name).first result ? result.send(VALUE_METHOD).freeze : nil end |
#supports_drop_table_if_exists? ⇒ Boolean
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.
42 43 44 |
# File 'lib/dm-migrations/adapters/dm-mysql-adapter.rb', line 42 def supports_drop_table_if_exists? true end |
#supports_serial? ⇒ Boolean
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.
37 38 39 |
# File 'lib/dm-migrations/adapters/dm-mysql-adapter.rb', line 37 def supports_serial? true end |