AshPostgres.Type behaviour (ash_postgres v2.11.0)

Copy Markdown View Source

Postgres-specific callbacks for Ash.Type.

Use this in addition to Ash.Type.

Summary

Callbacks

migration_type(constraints)

(optional)
@callback migration_type(Ash.Type.constraints()) :: term()

postgres_reference_expr(t, constraints, term)

(optional)
@callback postgres_reference_expr(Ash.Type.t(), Ash.Type.constraints(), term()) ::
  {:ok, term()} | :error

value_to_postgres_default(t, constraints, term)

(optional)
@callback value_to_postgres_default(Ash.Type.t(), Ash.Type.constraints(), term()) ::
  {:ok, String.t()} | :error

Return the text that will be placed into a migration as an attribute default.

The returned string is placed verbatim into generated migrations.

If this callback is not implemented, the migration generator falls back to EctoMigrationDefault.