How can I tell
identities to either be case sensitive or not? What is the switch? Here’s an example where I want the identity to not be case sensitive.
attribute :email, :string do
identity :unique_email, [:email]
Ash.Type.CiString the best way to achieve this or can I do it in the
You would want to use the
:ci_string type on the
:email attribute instead of regular
:string so that it ignores the case.
The out of the box Ash.Type’s are documented here.
The database in the migrations Ash generates will also use the appropriate type in those case ignore string attributes, so that the database identity constraint (a unique index) is enforced which ignores the case also.
Ash will also ensure that when using Postgres that the CITEXT extension is loaded within the migration.
UPDATE: I forgot to mention you need to ensure
/lib/myapp/repo.ex specifies the extensions you need:
defmodule MyApp.Repo do
use AshPostgres.Repo, otp_app: :myapp
def installed_extensions do