ash_postgres v0.38.6 AshPostgres.Migration View Source
Utilities for use in migrations
Link to this section Summary
Link to this section Functions
A utility for creating postgres enums for an Ash enum type.
In your migration, you can say:
def up() do AshPostgres.Migration.create_enum(MyEnumType) end
This code and example was copied from ecto_enum. I didn't use the library itself because it has a lot that would not currently be relevant for Ash. https://github.com/gjaldon/ecto_enum
Must be done manually, as the migration generator will not do it.
Additionally, altering the type must be done in its own, separate migration, which
@disable_ddl_transaction true, as you cannot do this operation
in a transaction.
defmodule MyApp.Repo.Migrations.AddToGenderEnum do use Ecto.Migration @disable_ddl_transaction true def up do Ecto.Migration.execute "ALTER TYPE gender ADD VALUE IF NOT EXISTS 'other'" end def down do ... end end
Keep in mind, that if you want to create a custom enum type, you will want to add
def storage_type, do: :my_type_name