The reason for declaring a database column as type string is that Rails migrations are meant to be database-agnostic. That’s why you could (as I’ve done on occasion) develop using Postgres as your database and deploy in production to Oracle.
It is useful to have a reference of how migration’s generic types map to database-specific types. The mappings for the databases most commonly used with Rails are in Table below.
Each connection adapter class has a native_database_types hash which establishes the mapping described in Table below. If you need to look up the mappings for a database not listed in Table below, you can pop open the adapter Ruby code and find the native_database_types hash, like the following one inside the PostgreSQLAdapter
NATIVE_DATABASE_TYPES = {
:primary_key => “serial primary key”.freeze,
:string => { :name => “character varying”, :limit => 255 },
:text => { :name => “text” },
:integer => { :name => “integer” },
:float => { :name => “float” },
:decimal => { :name => “decimal” },
:datetime => { :name => “timestamp” },
:timestamp => { :name => “timestamp” },
:time => { :name => “time” },
:date => { :name => “date” },
:binary => { :name => “bytea” },
:boolean => { :name => “boolean” },
:xml > { :name => “xml” }
}