Skip to content

PhoenixKit 2.0.0: A squashed migration chain, schema repair and safer dev mail

PhoenixKit 2.0.0 replaces the first 134 database migrations with one baseline, adds tools that check a live database against what the migrations should have built, and closes several security gaps in mail, uploads and user editing.

One baseline instead of 134 migrations

Migrations V01 to V134 are gone. A single V135 baseline takes their place and is now the lowest version this release can migrate from. A database at V135 or above upgrades as usual. A database below it makes mix ecto.migrate stop with PhoenixKit.Migrations.BelowFloorError, which names 1.7.236 as the release to install first. That refusal is a breaking change, which is why this release is 2.0.0: a ~> 1.7 requirement never resolves to it by accident.

Checking and repairing the schema

mix phoenix_kit.repair compares the live database with a generated description of what the migration chain should have created, reports what is missing, and can restore it. It has --dry-run and --json options. mix phoenix_kit.repair_uuid is for damaged uuid primary keys during a maintenance window. mix phoenix_kit.doctor gains checks built on the same description. Migration V164 repairs foreign keys left out by an old ordering bug on long-running installs.

The dev mailbox is now opt-in

PhoenixKit sends password-reset, magic-link and confirmation links by mail, and a new Phoenix app forwards /dev/mailbox with no login. When mail would land there, it is now written to the server log instead, and sign-in flows still succeed. Settings → Email Sending has a new Local dev mailbox section, shown only when the local adapter is in use, with the switch Deliver development mail to /dev/mailbox. The notice on the sign-in and registration pages no longer links to the mailbox.

Upload API and user editing

POST /api/upload and GET /api/files/:uuid/info now need a signed-in user. Uploads are owned by the uploader unless an Owner or Admin says otherwise, and are limited to 30 a minute per account. File info answers only to the file’s owner or an Owner or Admin. In the admin user form, profile fields such as the email can no longer be slipped in through custom fields, and changing another user’s password, status or confirmation now checks the actor’s rank in the code, not only in the form.

Mentions and names

Core adds @ mentions of people and # links to records, as a building block that modules can switch on in their text fields. Settings has two new options under Content Editor: Mentions and record links and Hide titles of records the reader can’t open. Comments now keep the author’s name as it was when written (V166). Wherever PhoenixKit shows a user’s name, it now falls back to the part of the email before the @, never the full address.

Slugs are now made by the locale_slug package. Accented Latin and Greek titles give better slugs, and Cyrillic titles are always transliterated. Stored slugs are not rewritten.

Upgrading

Run mix phoenix_kit.status first. At V135 or above, change the requirement to {:phoenix_kit, "~> 2.0"} and run mix phoenix_kit.update, which brings the schema to V166. Below V135, install 1.7.236, migrate, then upgrade. Feature modules that pin ~> 1.7 block mix deps.get until they release a widened requirement, so stay on ~> 1.7 until yours have. On a development machine, mail stops reaching /dev/mailbox until you turn the switch on. Callers of the file info endpoint without a login now get a 401.

Full release notes: PhoenixKit 2.0.0

2.0.0 · 10 August 2026

⚠️ Upgrade requirement — databases below V135 must stop at 1.7.236 first

The migration chain is squashed (#689). V01..V134 are replaced by a single V135 baseline, and V135 is now the chain’s floor: this release no longer carries the migration modules below it.

  • At V135 or above (any install kept current through 1.7.x): nothing to do. Upgrade normally.
  • Below V135: mix ecto.migrate raises PhoenixKit.Migrations.BelowFloorError and refuses, rather than migrating. Install 1.7.236 — the migration bridge, the last release carrying the full pre-squash chain — run its migrations until the reported version is at least V135, and only then upgrade to this release. The error message names the bridge and the procedure.

Check where you are with mix phoenix_kit.status before upgrading.

This is why the version is 2.0.0. Refusing a below-floor install rather than migrating it is a breaking upgrade contract, and a major version is what stops a host from being carried across the floor by a routine mix deps.update: a {:phoenix_kit, "~> 1.7"} requirement does not resolve to 2.0, so reaching this release is now a deliberate act with a chance to read this section first.

Feature modules need a widened pin before you move to ~> 2.0

phoenix_kit_* packages pin core at ~> 1.7.x, which does not accept 2.0. So {:phoenix_kit, "~> 2.0"} alongside a module that has not yet widened its requirement is an unsatisfiable dependency: mix deps.get fails and names the conflict. Each module needs a widened requirement and a patch release; none of them call migration internals, so the change is the pin itself.

If you stay on {:phoenix_kit, "~> 1.7"}, nothing changes for you — that requirement does not resolve to 2.0, which is the same property that protects below-floor installs. Move your own pin to ~> 2.0 once the modules you use have released theirs; until then the failure is a resolver error at mix deps.get time, not a broken build.

Nothing is rolled back through this release either: a below-floor install cannot down through it.

Added

  • Verify-and-repair for the schema (#689). mix phoenix_kit.repair compares a live database against a generated manifest of what the chain should have produced (PhoenixKit.Migrations.ExpectedSchema) and can restore what is missing; mix phoenix_kit.repair_uuid is the maintenance-window path for uuid primary-key damage, building its unique index CONCURRENTLY. Both report before they write, and mix phoenix_kit.doctor grew checks that use the same manifest.

  • PhoenixKit.Migrations.BelowFloorError (#689) — the explicit refusal described above, carrying the database’s version, the floor, and the bridge release to install. Names 1.7.236 rather than “the last 1.7.x” (#690).

  • dev_mailbox_enabled setting and its toggle (#697) on /admin/settings/email-sending — the section appears only when the resolved transport is the local mailbox, and switching it on states the consequence.

  • PhoenixKit.Mailer.resolved_send_path/0 (#697) — the one answer to “where will this message actually go”: {:integration, uuid} or {:mailer, module, adapter}.

  • Upload rate limiting (#697) — RateLimiter.check_upload_rate_limit/1, 30/min keyed on the uploading account (never the attributed owner, which would hand an admin a fresh window per victim uuid).

  • mix prerelease (#690) — the release gate: locked deps, a production compile, quality.ci, deps.audit, hex.audit, docs, hex.build, and mix phoenix_kit.release_check (CHANGELOG heading, migration/version sync, clean tree, branch, tag collision). It catches release-metadata drift that mix precommit structurally cannot.

  • Cross-module @ mentions and # record links (#692). PhoenixKit.Mentions — typing @ offers people, # offers records from every installed module. The mention is stored as a self-contained token carrying its own label, so it survives copy-paste, export, edit history and a module being uninstalled, and degrades to readable text rather than a broken link. Titles are re-resolved per viewer at render: a reader who may not open a record never sees a title refreshed after the fact, and visibility fails CLOSED for any resource type whose module declares no check. Adds phoenix_kit_mentions and phoenix_kit_access_requests (V165), the <.mention_text> component, use PhoenixKit.Mentions.Live for the write side, and mentions opt-in attributes on <.textarea> and the multilang textarea. Settings: mentions_enabled (default on), mentions_redact_titles (default off).

  • Frozen comment attribution (#692, V166). author_display_name, attribution_mode, attributed_project_uuid and attributed_label on phoenix_kit_comments: a name resolved at render time re-signs every comment its author ever wrote, so what the reader was shown is pinned at write. user_uuid is never cleared — posting as a project changes what the public sees and nothing else.

  • Notifications.fan_out_from_activity/2 (#692) — routes one committed activity entry to many recipients through the same prefs/channel/digest machinery, without inserting extra feed rows.

  • before_user_delete/1 module hook (#692) — runs for every discovered module before a user row is deleted, while their related rows still exist. Best-effort: a hook that raises or throws is logged and never aborts the deletion.

  • ImageProcessor.sanitize/3 (#692) — re-encodes an untrusted upload to known-good bytes (detected-and-allowlisted decoder, first frame only, metadata stripped, local resource ceilings, declared-pixel-count refusal). A primitive: no core upload path calls it yet.

  • User-dashboard route auto-discovery (#692) — an external module’s user_dashboard_tabs/0 entry carrying a live_view now gets its route generated, mirroring the admin-tab path.

Changed

  • ⚠️ Local dev-mailbox delivery is now opt-in (#697, issue #687). A stock mix phx.new app puts Swoosh.Adapters.Local in dev.exs and forwards /dev/mailbox with no authentication — and PhoenixKit sends password-reset, magic-link, confirmation, email-change and invitation mail through it, each carrying a single-use token that exists nowhere else (only its SHA-256 hash is stored). Anyone who could reach the dev server could read those links.

    New setting dev_mailbox_enabled, default off. While it is off and the resolved transport is the local mailbox, mail is not handed to the adapter: recipient, subject and body go to the server log, and the call returns {:ok, %{suppressed: true, …}} so auth flows still succeed. The gate sits before the tracking pipeline, so a suppressed message is not recorded as sent. Turn it on for a closed environment at /admin/settings/email-sending, or configure a send integration there.

    The cost, named: an upgraded dev install stops filling /dev/mailbox until someone flips the switch. Every suppressed send says so in the log, the development notice changes visibly, and the settings page carries a banner.

  • ⚠️ GET /api/files/:uuid/info now requires authentication (#697) and answers only for a file the caller owns, or to an Owner/Admin — with an identical not_found for a foreign and a missing file, so it is no longer an existence oracle. This is documented host API: a caller using it anonymously, such as a public gallery front-end, must now authenticate.

  • Config.mailer_local?/0 resolves the way deliver_email/2 actually sends (#697, issue #687). It read config :phoenix_kit, PhoenixKit.Mailer alone, so it was wrong in both directions: false on a delegation-mode host whose real mailer is Local, and true on a host with the installer-written Local block that delegates to a real mailer. New PhoenixKit.Mailer.resolved_send_path/0 is the single source — default send integration → delegated host mailer → built-in — and anything asking “does mail land in the local mailbox?” must go through it rather than a raw config read.

  • The development notice no longer links to /dev/mailbox (#697). It was rendered to anonymous visitors on the login, registration, forgot-password and magic-link pages — a signpost for a developer and a map for everyone else. The copy now reflects the gate’s state instead.

  • Slug generation moved onto the locale_slug package (#693) — a new required runtime dependency, pure Elixir with no dependencies of its own. PhoenixKit.Utils.Slug keeps its public shape (slugify/2, transliterate/1, ensure_unique/2) and delegates the rule. The hand-rolled table could not express a locale, and produced gro-e-fu-ball for Größe Fußball, caf for Café, n-c-d-t-st for Ünïcödé Tëst, and an empty slug for any Cyrillic-only title whose caller forgot transliterate: true — which callers read as “no slug yet” and regenerated forever. Romanization is now always on (:transliterate is accepted and ignored), :locale and :max_length are new options, and Greek is covered.

    ⚠️ Stored slugs are not rewritten and existing URLs are unaffected, but a caller that re-derives a slug from a title to look up a row now derives a different string. This is not confined to Cyrillic content — see the accented Latin examples above.

    ⚠️ Slug.transliterate/1 now lower-cases its result. The old table had only lowercase Cyrillic keys, so it left case alone and half-mapped uppercase input (Кашпо → Кashpo). Core’s only caller downcases first; external callers that need the original casing must keep their own copy.

  • locale_slug pinned ~> 0.1.0 (#693 post-merge review), not ~> 0.1. The looser form admits every 0.x, and the exposure is not the API but the OUTPUT: a revised romanization table changes the slug a host derives from the same title, and slugs are persisted in URLs. Adopting a new minor should be a deliberate PhoenixKit release, not a mix deps.update side effect.

  • One canonical User.display_name/1, and no more published email addresses (#692). Half a dozen private copies of the name chain ended || user.email, which is how a public issue board came to print commenters’ full addresses next to their words. The chain is now organization name → first+last → username → the email’s local part → "User", with every rung trimmed and rejected when blank. Never the full address.

Fixed

  • admin_update_user_password/3 wrote the password hash for any caller (#690). The rank rule lived only in the admin edit form, which asks can_manage_user_credentials?/2 to hide the UI and refuse the event — the context function itself asked nothing. The actor was already threaded through context for the audit row, so it now authorizes as well as audits: an actor present and out of rank is refused, and an absent actor stays the system path for seeds, migrations and mix tasks. Not reachable through the shipped UI at the time — this closed the second caller before it existed. See also the custom_fields bypass below, which was the second caller.
  • POST /api/upload and GET /api/files/:uuid/info required no authentication (#697). Both live in a scope that fetches a user but never requires one. Upload took the file owner from params["user_uuid"] with the check never written, so an anonymous client could attribute a 100 MB upload — and the variant-processing job it enqueues — to any account. File-info handed out freshly-signed capability URLs for any file uuid to anyone, defeating the signing scheme, and its 200/404 split was a file-existence oracle. Upload now authorizes before touching the body (401 when unauthenticated, the user_uuid override honored only for an Owner/Admin, otherwise attributed to the uploader) and is rate-limited at 30/min per account.
  • update_user_status/3 and toggle_user_confirmation/2 wrote for a malformed actor (#696). Both ended in a catch-all that performed the unchecked write. That branch exists for callers with no actor — seeds, mix tasks, and Users.Referrals expiring an account — but it also swallowed an :actor that was present and the wrong shape: a map decoded from JSON by a host controller, a bare uuid string. toggle_user_confirmation/2 is the serious one, since its unchecked path clears confirmed_at and locks the target out of every confirmation-gated page. Both now use the three-branch shape from admin_update_user_password/3. An explicit actor: nil still takes the system path, identically in all three.
  • A never-analyzed table was sized as 0 rows (#695). reltuples = -1 (PostgreSQL ≥ 14: never vacuumed or analyzed — a pg_restore, a CREATE TABLE AS, logical replication, autovacuum off) was collapsed to 0, so V163’s size guard read “small enough, proceed” for a table nobody had ever measured. A restored 200k-row table took ACCESS EXCLUSIVE for a full rewrite mid-deploy — the exact event the guard exists to prevent. estimated_rows/3 now answers :unknown, V163 defers on it, and mix phoenix_kit.repair_uuid prints “size unknown — never analyzed” rather than “~0 rows” to whoever is sizing a maintenance window.
  • mix phoenix_kit.repair --adopt stamped over a corrupt version comment (#695). Repair.Probe collapsed “no comment” and “unreadable comment” into the same nil, so the operator was told the comment was missing while the table said v164, and adopt overwrote it — destroying the only record of what the last person believed. Unreadable is now its own state and refuses instead.
  • One flaky catalog read could abort V164 mid-run (#695). Its post-ADD verification moved to a probe that raises, where the check it replaced returned false; V164 has no rescue and runs with @disable_ddl_transaction, so a single failed read on one of ~70 constraints aborted with earlier repairs already committed and the version comment never stamped, replaying the whole version next time. A probe failure is now one {:failed, …} summary line.
  • comments_fk_on_delete/1 read a constraint by name alone (#695), so a CHECK or a foreign key on a different column owning fk_comments_user_uuid answered for the real one — an impostor’s confdeltype of 'n' read as “already SET NULL, nothing to do” and the genuinely missing foreign key was never created.
  • mix phoenix_kit.status --verbose crashed on an unreadable version comment (#695) — the non-verbose path reported the state correctly and the same run then died with CaseClauseError immediately after printing a correct tree.
  • A comment-less database reported itself as version 1 (#694). A database that is current but has lost its phoenix_kit version comment — the half-installed or adopted state — resolved to version 1, which is below the floor, so mix phoenix_kit.update answered “install the 1.7.x bridge first”: the one instruction the migrator refuses to give, because replaying the pre-squash chain over a possibly-current database backfills still-NULL tracked columns with invented uuids and then deletes the rows that match no user. The state is now distinct from both a real version and “not installed”, and routes to doctor + restamp. mix phoenix_kit.status reports it instead of crashing.
  • mix phoenix_kit.repair crashed on the anomaly it exists to diagnose (#694). Repair.Probe.read_comment/2 used String.to_integer/1 eleven lines below a docstring promising it never raises, so the exact hand-edits the migrator documents ('v164', ' 164') ended the run in a bare ** (ArgumentError) argument error.
  • ensure_uuid_v7_function/1 aborted migrations on DBA-owned functions (#690). Its insufficient_privilege rescue was dead code in migration context: Ecto.Migration.execute/1 only queues the statement, so the error arrives at flush time where no rescue can reach it. That is the topology PhoenixKit.Migration’s own moduledoc tells a DBA to adopt, and the helper runs on every delta upgrade. The un-ownable case is now excluded before the statement is queued, via pg_has_role — so a function owned by a role the migrating role belongs to is still refreshed.
  • V164 warned “reconcile by hand” about the foreign key it then repairs (#690), and verified that key by name alone (#694) — a CHECK constraint owning the same name read as present, the guarded ADD failed with 42710 into an EXCEPTION WHEN OTHERS, and the outcome was reported :created with no foreign key. contype = 'f' is now part of the test.
  • V163’s size guard is checked before castability (#694). castable?/3 is a full-table scan, so asking it first made the deferral path pay an unbounded sequential scan on exactly the tables the size limit exists to keep out of mix ecto.migrate.
  • V165 recorded the schema version as 163 (#692 post-merge review). Every other migration in the chain stamps its own number going up; V165’s up/1 stamped two behind, so an install migrated to exactly 165 reported 163 — behind where it started — and the next ensure_current/2 re-ran V164 and V165. A full run to head hid it, because V166 stamps immediately afterwards.
  • The @ mention typeahead no longer issues ~128 queries per keystroke (#692 recheck). Mentions.Users.search/2 over-fetched and then called Scope.for_user/1 per candidate (roles + permissions each), so a full page of results paid two round trips per row. The admin-area rule is now one SQL EXISTS for Owner/Admin and one for any role_permissions grant, with the limit applied in the database.
  • Access requests no longer accept free-form type/uuid payloads unthrottled (#692 recheck). AccessRequests.request/4 now requires a type registered in ResourceLinks.handlers/0, a castable uuid, and a per-account rate limit (10 / 10 minutes) — the partial unique index only stops repeats for the same resource.
  • ExpectedSchema knew nothing of V165/V166 objects (#692 recheck). The schema manifest was still stamped at V164, so release_check blocked the release and repair/verify would have been blind to the two new tables and the comment-attribution columns. V165/V166 objects are now hand-declared (same post-generation path as V164) and chain_hash restamped over the 32 shipped files.
  • A record’s NAME could inject a markdown link into every mention of it (#692 post-merge review). to_markdown/2 escapes the value it splices into [text](url) on the reasoning that the token grammar refuses ] — true of the author’s stored label, false of the live resolved title, which is the record’s current name and unconstrained. Renaming a record to Evil](https://evil.example) turned every markdown-rendered mention of it, for every reader, into a link to the attacker’s URL. ] is now escaped, and the destination uses the CommonMark angle form so a ) in a handler-supplied path cannot close it either.
  • <.mention_text> told hosts to use PhoenixKit.Mentions.RequestAccess (#692 post-merge review), which does not exist — the module is PhoenixKit.Mentions.Live, and it needs <.access_request_dialog> rendered alongside it or the click sets an assign nothing reads.
  • The credential rank rule was bypassable through custom_fields (#691). Auth.update_user_fields/2 routes a custom_fields key whose name matches a profile field out of the JSONB column and writes it to the schema — including :email, with no confirmation-token flow. The admin user form handed it params["custom_fields"] verbatim, so the Map.drop that protects the profile params never saw it: an actor holding only the users permission could point an Owner’s address at their own inbox and then take the account through the public password-reset page. The form now filters those names out of custom_fields unconditionally, admin_update_user_password/3 enforces the rank rule in the context rather than trusting its callers, and the refusal no longer reaches a clause that expects a changeset (which crashed the LiveView after the profile write had already committed).
  • A present-but-malformed :admin_user no longer takes the unchecked system path (#691). Only an absent actor is a seed/migration/mix-task caller; a value of the wrong shape is a caller that meant to supply one, and is refused.
  • The credential refusal path no longer raises instead of refusing (#691 post-merge review). admin_update_user_password/3 takes its target unguarded and can_manage_user_credentials?/2 answers false for a non-%User{}, so a host passing a JSON-decoded map as the target reached a refusal branch that pattern-matched %User{} and interpolated user.uuid — FunctionClauseError and KeyError respectively, where the pre-#691 code returned {:error, :insufficient_permissions}. A fail-closed guard that crashes has failed differently, not safely.
  • The form’s filter no longer keeps a second hand-maintained copy of the field whitelist (#691 post-merge review). It read a literal list that duplicated the one inside update_user_fields/2; adding a profile field to the context and forgetting the copy would have re-opened the bypass for that field, silently and with the existing tests still green. Both now read Auth.updatable_profile_fields/0, and a new test poisons custom_fields with every name in it, so coverage grows with the list.

Changed

  • Auth.updatable_profile_fields/0 (#691 post-merge review) — new public reader for the fields update_user_fields/2 writes to the schema, so callers filtering untrusted params read the rule instead of restating it. update_user_fields/2’s docs now state outright that it does not authorize and that :email / :username are credentials.
  • StatusReport.next_action/3 gained {:fix_version_comment, message} (#694 post-merge review) — the state existed in the function but not in the action() type, so dialyzer proved the consumer clause unreachable and mix precommit failed. The comment-less guard also now fails closed: it required an affirmative “the comment reads 1” only after review, having previously fallen through to the destructive advice whenever the confirming query could not answer.
  • The admin form logs the identity fields it strips from custom_fields (#691 post-merge review). The page renders a real input for every one of those names, so such a key on the wire means a client composed its own payload — a stronger signal than the rank refusal the context already logs, and it was being discarded without a word.

PhoenixKit 2.0.0. Install or update: {:phoenix_kit, "~> 2.0"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.