Class: Chicago::Database::MysqlStrategy Private

Inherits:
ConcreteSchemaStrategy show all
Defined in:
lib/chicago/database/concrete_schema_strategies.rb

Overview

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

MySql-specific database schema strategy

Instance Method Summary collapse

Methods inherited from ConcreteSchemaStrategy

for_db, #id_column, #indexes, #migration_options, #string_type

Instance Method Details

#column_hash(column) ⇒ 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.



166
167
168
# File 'lib/chicago/database/concrete_schema_strategies.rb', line 166

def column_hash(column)
  column.to_hash.merge :column_type => db_type(column)
end

#db_type(column) ⇒ 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.



170
171
172
173
# File 'lib/chicago/database/concrete_schema_strategies.rb', line 170

def db_type(column)
  return :enum if column.elements && column.elements.size < 65_536
  super(column)
end

#integer_type(min, max) ⇒ 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.



182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/chicago/database/concrete_schema_strategies.rb', line 182

def integer_type(min, max)
  return :integer unless min && max

  case
  when in_numeric_range?(min, max, TINY_INT_MAX)   then :tinyint
  when in_numeric_range?(min, max, SMALL_INT_MAX)  then :smallint
  when in_numeric_range?(min, max, MEDIUM_INT_MAX) then :mediumint
  when in_numeric_range?(min, max, INT_MAX)        then :integer
  when in_numeric_range?(min, max, BIG_INT_MAX)    then :bigint
  else
    raise ArgumentError.new("#{min} is too small or #{max} is too large for a single column")
  end
end

#table_optionsObject

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.

Returns table options for a dimension or fact table.

Dimension tables are defined as MyISAM tables in MySQL.



178
179
180
# File 'lib/chicago/database/concrete_schema_strategies.rb', line 178

def table_options
  {:engine => "myisam"}
end