Repairs missing UUID columns for databases upgrading from PhoenixKit < 1.7.0.
Problem
PhoenixKit 1.7.x added UUID columns to all legacy tables in migration V40.
However, some migrations before V40 (e.g., V31) use Ecto schemas that expect
the uuid column to exist. This creates a chicken-and-egg problem for users
upgrading from older versions.
Solution
This module detects the condition and adds UUID columns BEFORE running migrations, ensuring V31+ can use Ecto schemas without errors.
Creates the uuid_generate_v7() PostgreSQL function (same as V40) and uses
it for all UUID column defaults and backfills, ensuring UUIDv7 consistency
from the start. V40 later runs CREATE OR REPLACE which is a safe no-op.
When It Runs
Called automatically by mix phoenix_kit.update when:
- Current database version is < 40
- Tables exist but are missing uuid columns
Tables Affected
Only repairs tables that:
- Exist in the database
- Are missing the uuid column
- Are used by Ecto schemas in migrations before V40
Primary tables:
- phoenix_kit_users (used by all auth operations)
- phoenix_kit_users_tokens (used by login/registration)
- phoenix_kit_user_roles (used by role system)
- phoenix_kit_user_role_assignments (used by role system)
- phoenix_kit_settings (used by V35, V36)
- phoenix_kit_email_templates (used by V31)
Summary
Functions
Checks if UUID repair is needed and performs it if necessary.
Checks if repair is needed without performing it.
Functions
Checks if UUID repair is needed and performs it if necessary.
Returns:
{:ok, :not_needed}- No repair needed (fresh install or already has uuid){:ok, :repaired}- Repair was performed successfully{:error, reason}- Repair failed
Checks if repair is needed without performing it.
Useful for dry-run or status checks.