Use integers or enum to represent attoms in AshPostgres

Currently, if I add an atom attribute in my resource, it will create a text column in that resource table.

Is there some built-in way to use integer or enum to represent the same data instead?

The best way to do it currently would be to use an enum type. You’d create the enum type in postgres yourself, and then override it using migration_types.

postgres do
  migration_types your_field: :the_enum_type_name

Then you’d use an Ash enum type, like so

defmodule YourEnum do
  use Ash.Type.Enum, values: [:foo, :bar, :baz]
1 Like