Ecto Migration Field Types

There is a nice table showing the available data types used in Ecto Schemas:

But I cannot find a corresponding list that enumerates the possibilities available to an Ecto Migration. They are similar, but they are not always the same. Does anyone have such a list? And should that be a part of the docs?

Many thanks!



That’s the link I meant to include in my post (now edited). That lists the data types for SCHEMAS. It’s similar, but not the same for MIGRATIONS. Thus the post. Where is there a similar list for types available within migrations?

1 Like

This depends on the underlying database adapter. You can always use fragment for the type as well and specify anything you like.

1 Like

I figured out how to take advantage of PostGreSQL’s inet data type following Pedro’s excellent article:

add :ip, :inet, null: false, default: fragment("''::inet")

Note that you can just put whatever PostGres data type as the 2nd argument (no need to use fragment there). The fragment macro was however useful to supply a default argument for that field.

There is still the correlating types used by the schema, but this gets me so I’m able to create the database the way I want. Thanks all!


The list of types defined for Postgres is in postgrex extensions.