PostgreSQL has great support for objects stored as JSON. This is useful for those moments when you need to store data that could be variably structured, such as responses from other services’ APIs, or data that frequently travels together within your relational tables.
A common trade-off for mixing scalar column data types (like varchar or integer) with column data types that handle more-complicated objects (like JSON) is that ORMs or data mappers sometimes can’t introspect on them for you, which means it becomes much harder to query that data.
Using Ecto’s embedded_schema helps introspect on those known values, but it doesn’t really assist you with querying those fields in SQL. This is where I became extremely greatful for Ecto’s escape hatch: fragment().