Postgres Data Types in Ecto

How can we use some of the other data types in Postgres with Ecto?

For example, using the smallint data type?


You can use some of them by simply creating them in the migrations and keeping the ecto runtime type, e.g. :text => :string and probably :smallint => :integer. For all other cases there’s Ecto.Type to map castable values => runtime values and runtime values <=> database values.

1 Like