Module: DataMapper::Adapters::MysqlAdapter::Migration::SQL
- Defined in:
- lib/dm-mysql/mysql_adapter.rb
Instance Method Summary collapse
-
#create_table_statement(repository, model) ⇒ Object
Engine, Character Set and Collate are default options which are inherited from options set in the adapter.
Instance Method Details
#create_table_statement(repository, model) ⇒ Object
Engine, Character Set and Collate are default options which are inherited from options set in the adapter.
See dev.mysql.com/doc/refman/5.1/en/create-table.html for details on how to set the various table options
Returns
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/dm-mysql/mysql_adapter.rb', line 17 def create_table_statement(repository, model) <<-EOS.compress_lines.rstrip #{super} ENGINE = #{ model.table_opts[:engine] ? model.table_opts[:engine] : 'InnoDB' } CHARACTER SET #{character_set} COLLATE #{collation} #{ "AVG_ROW_LENGTH = #{model.table_opts[:avg_row_length]}" if model.table_opts[:avg_row_length] } #{ "CHECKSUM = #{model.table_opts[:checksum]}" if model.table_opts[:checksum] } #{ "COMMENT = '#{model.table_opts[:comment]}'" if model.table_opts[:comment] } #{ "CONNECTION = '#{model.table_opts[:connection]}'" if model.table_opts[:connection] } #{ "DATA DIRECTORY = '#{model.table_opts[:data_directory]}'" if model.table_opts[:data_directory] } #{ "DELAY_KEY_WRITE = #{model.table_opts[:delay_key_write]}" if model.table_opts[:delay_key_write] } #{ "INDEX DIRECTORY = '#{model.table_opts[:index_directory]}'" if model.table_opts[:index_directory] } #{ "INSERT_METHOD = #{model.table_opts[:insert_method].upcase}" if model.table_opts[:insert_method] } #{ "KEY_BLOCK_SIZE = #{model.table_opts[:key_block_size]}" if model.table_opts[:key_block_size] } #{ "MAX_ROWS = #{model.table_opts[:max_rows]}" if model.table_opts[:max_rows] } #{ "MIN_ROWS = #{model.table_opts[:min_rows]}" if model.table_opts[:min_rows] } #{ "PACK_KEYS = #{model.table_opts[:pack_keys]}" if model.table_opts[:pack_keys] } #{ "PASSWORD = #{model.table_opts[:password]}" if model.table_opts[:password] } #{ "ROW_FORMAT = #{model.table_opts[:row_format]}" if model.table_opts[:row_format] } #{ "TABLESPACE #{model.table_opts[:tablespace]}" if model.table_opts[:table_opts] } #{ "UNION = #{model.table_opts[:union]}" if model.table_opts[:union] } EOS end |