AshPrefixedId.PostgresExtension (ash_prefixed_id v0.2.0)

View Source

AshPostgres custom extension that provides uuid_generate_v7() and timestamp_from_uuid_v7() PostgreSQL functions.

Usage

Add to your Repo's installed_extensions:

defmodule MyApp.Repo do
  use AshPostgres.Repo, otp_app: :my_app

  def installed_extensions do
    ["ash-prefixed-id", ...]
  end
end

Then generate and run the migration:

mix ash.codegen install_prefixed_id_extension
mix ash.migrate

A note on LEAKPROOF

timestamp_from_uuid_v7/1 is intentionally NOT marked LEAKPROOF. LEAKPROOF only matters when a function appears in a query that crosses a security barrier (Row Level Security, security_barrier views) and you want the planner to push the predicate through that barrier. Ash's authorization is application-layer (Ash policies) and AshPostgres does not enable RLS or security-barrier views by default, so the attribute provides no practical benefit for typical users.

Marking a function LEAKPROOF requires PostgreSQL superuser, which blocks every managed Postgres provider (RDS, Cloud SQL, Heroku, Supabase, Neon, Aiven, etc.). Defaulting to portable migrations is worth the lost optimizer hint.

Users who actually rely on RLS / security-barrier views can mark the function leakproof themselves as superuser, after the migration runs:

ALTER FUNCTION timestamp_from_uuid_v7(uuid) LEAKPROOF;

Summary

Functions

extension()