Skip to content

Instantly share code, notes, and snippets.

View brlo's full-sized avatar
🦎
...

Rodion V brlo

🦎
...
View GitHub Profile
@brlo
brlo / ar_migrate.rb
Created April 8, 2016 16:25 — forked from icyleaf/ar_migrate.rb
ActiveRecord type of integer (tinyint, smallint, mediumint, int, bigint)
# activerecord-3.0.0/lib/active_record/connection_adapters/mysql_adapter.rb
# Maps logical Rails types to MySQL-specific data types.
def type_to_sql(type, limit = nil, precision = nil, scale = nil)
return super unless type.to_s == 'integer'
case limit
when 1; 'tinyint'
when 2; 'smallint'
when 3; 'mediumint'
when nil, 4, 11; 'int(11)' # compatibility with MySQL default