Module: DataMapper::Migrations::MysqlAdapter::SQL
- Included in:
- DataMapper::Migrations::MysqlAdapter
- Defined in:
- lib/dm-core/migrations.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#character_set ⇒ Object
private
TODO: document.
-
#collation ⇒ Object
private
TODO: document.
-
#create_table_statement(connection, model, properties) ⇒ Object
private
TODO: document.
-
#property_schema_hash(property) ⇒ Object
private
TODO: document.
-
#property_schema_statement(connection, schema) ⇒ Object
private
TODO: document.
-
#schema_name ⇒ Object
(also: #db_name)
private
TODO: document.
-
#show_variable(name) ⇒ Object
private
TODO: document.
-
#supports_drop_table_if_exists? ⇒ Boolean
private
TODO: document.
-
#supports_serial? ⇒ Boolean
private
TODO: document.
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.
TODO: document
404 405 406 |
# File 'lib/dm-core/migrations.rb', line 404 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.
TODO: document
410 411 412 |
# File 'lib/dm-core/migrations.rb', line 410 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.
TODO: document
369 370 371 |
# File 'lib/dm-core/migrations.rb', line 369 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.
TODO: document
375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
# File 'lib/dm-core/migrations.rb', line 375 def property_schema_hash(property) schema = super if schema[:primitive] == 'TEXT' schema[:primitive] = text_column_statement(property.length) schema.delete(:default) end if property.primitive == Integer && property.min && property.max schema[:primitive] = integer_column_statement(property.min..property.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.
TODO: document
392 393 394 395 396 397 398 399 400 |
# File 'lib/dm-core/migrations.rb', line 392 def property_schema_statement(connection, schema) statement = super if supports_serial? && schema[:serial] statement << ' AUTO_INCREMENT' end statement end |
#schema_name ⇒ Object Also known as: db_name
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
359 360 361 362 |
# File 'lib/dm-core/migrations.rb', line 359 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.
TODO: document
416 417 418 419 |
# File 'lib/dm-core/migrations.rb', line 416 def show_variable(name) result = query('SHOW VARIABLES LIKE ?', name).first result ? result.value.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.
TODO: document
353 354 355 |
# File 'lib/dm-core/migrations.rb', line 353 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.
TODO: document
347 348 349 |
# File 'lib/dm-core/migrations.rb', line 347 def supports_serial? true end |