Skip to content

Instantly share code, notes, and snippets.

View diegobarros0701's full-sized avatar
🎯
Focusing

Diego Barros diegobarros0701

🎯
Focusing
View GitHub Profile
@diegobarros0701
diegobarros0701 / ar_migrate.rb
Created October 12, 2017 18:12 — 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