Hi! I’ve created an Amount type using Ash.Type.NewType like so:
defmodule MyApp.Types.Amount do
use Ash.Type.NewType,
subtype_of: :decimal,
constraints: [precision: 19, scale: 2]
This is working fine, but since I’m using Postgres, I’d like to enforce the constraints at the DB level: I want Ash to generate migrations using NUMERIC(19, 2). Would it be possible to do something like this?
@impl true
def storage_type(_constraints) do
[:numeric, precision: 19, scale: 2]
end
Maybe we could augment NewType’s API and add an option like enforce_constraints_in_database: true? If the subtype supports it, this would take the constraints options and pass them down to Ecto.






















