fireproofsocks
There is a nice table showing the available data types used in Ecto Schemas: Ecto.Schema — Ecto v3.14.0
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!
Trending in Questions
One of my LiveView view’s has a very heavy javascript dependency so I want to avoid loading it for every page on the site, while still us...
New
Hi all!
I know that quite a few people use Phoenix LiveView but it is hard to get a more up-to-date list of folks/companies using it. I ...
New
Hello everyone!
I am new to coding with Elixir/Erlang. And i am looking for some utilities for fuzzing testing like AFL++.
Does anyone ...
New
I’m very new to Elixir, so sorry if this is a silly question:
I am wondering what happens to the mailbox of a process when the machine i...
New
I load tested a plain Phoenix chat app backed by Postgres with 100 million messages in it, everything on default settings, to see what br...
New
I don’t suppose you can lazy load a library depending on runtime data? For example if it’s a certain user they can lazy load ‘library A’ ...
New
Hi all,
I’m trying to get Pi working well as an external agent inside Tidewave.ai via ACP.
Tidewave’s settings make it possible to add ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hi everyone :waving_hand:
I’ve been working on PhiaUI, an open-source UI component library for Phoenix LiveView, and I wanted to share i...
New
On November 23, 2026, an unauthorized third party exploited a vulnerability in hex.pm (CVE-2026-129514, CVSS 10.0) that let them run comm...
New
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New
Popcorn, the library that runs Elixir code in the browser, is now stable :popcorn:
This is possible because it now builds on a very stab...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #code-sync
- #exunit
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #ai
- #authentication
- #elixirconf-us
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-eu
- #distillery
- #security
- #processes
- #api
- #forms
- #hex











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
mikemccall
This?
fireproofsocks
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?
benwilson512
This depends on the underlying database adapter. You can always use
fragmentfor the type as well and specify anything you like.fireproofsocks
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("'0.0.0.0'::inet")Note that you can just put whatever PostGres data type as the 2nd argument (no need to use
fragmentthere). Thefragmentmacro 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!
kip
The list of types defined for Postgres is in postgrex extensions.
DidactMacros
Seems :string is not included in this list. I know bit_string is here, but the form used in ecto migrations is :string. Just an FYI for other readers.
garrison
There is a mapping from Ecto aliases (like
:string) to database types. For Postgres I believe that mapping is right here. So as you can see:stringis converted to:varchar. If the type is unknown it is converted to a string and then sent verbatim, which is why you can use any db-specific type (like:citext) even if it’s not present there.Note that the
:stringtype is not equivalent to:textwith Ecto/Postgres, because for some reason:stringactually becomesvarchar(255)- that is to say it has a limit of 255 characters.I have no idea where that default size is set (or why, for that matter).
DidactMacros
That’s a great link you provided.
One might have to rummage through (ctlr f) for mappings for things like :text. It seems the preference is to phx.gen.schema, as access to full schema mappings is readily available.
jswanner
255 is an old suggested default size for
varchar, there were reason for it at the time, there’s no great reason to continue to use it anymore. For Postgres, unless you want to enforce some hard limit on the size of a string field, it’s best to usetextas your default character field type.kip
Another reason to use
textis that Postgres string functions typically define their parameters astext, and hence you’re less likely to get type mismatch errors on them.varcharis treated somewhat as a domain overtextand hence not exactly the same.