refactor: update migration for UUIDv7 and explicit FK constraint

- Add on_delete: :restrict to users.role_id foreign key
- Update roles.id to use uuid_generate_v7() default
- Regenerate resource snapshots
This commit is contained in:
Moritz 2026-01-06 18:14:18 +01:00
parent 82ec4e565a
commit 402a78dd0a
3 changed files with 140 additions and 0 deletions

View file

@ -22,6 +22,7 @@ defmodule Mv.Repo.Migrations.AddAuthorizationDomain do
column: :id,
name: "users_role_id_fkey",
type: :uuid,
on_delete: :restrict,
prefix: "public"
)
end

View file

@ -0,0 +1,21 @@
defmodule Mv.Repo.Migrations.UpdateRoleToUuidv7 do
@moduledoc """
Updates resources based on their most recent snapshots.
This file was autogenerated with `mix ash_postgres.generate_migrations`
"""
use Ecto.Migration
def up do
alter table(:roles) do
modify :id, :uuid, default: fragment("uuid_generate_v7()")
end
end
def down do
alter table(:roles) do
modify :id, :uuid, default: fragment("gen_random_uuid()")
end
end
end