mix mishka_cms_core.purge_draft_archival (Mishka CMS Core v0.0.1)

Copy Markdown View Source

Deletes runtime drafts that were discarded back when discarding was a soft delete.

MishkaCmsCore.Runtime.PageDraft and its two siblings used AshArchival until 2026-08-01: a discard set archived_at and a base filter hid the row. Removing the extension took the filter with it, so those rows became visible again — a draft its author threw away now sits in the picker looking like work in progress. Run this once, on any database that existed before that date.

MishkaCmsCore.Runtime.DraftArchivalPurge holds the logic and explains exactly which rows match and why a published draft is never one of them.

Command line options

  • --dry-run — report what would be deleted and delete nothing
  • --quiet — print nothing; the exit status still reflects success

Run it BEFORE migrating

The migration that drops archived_at destroys the only thing separating a discarded draft from a live one. After that, no query can tell them apart and this task has nothing to work with — it reports zero and exits cleanly, which is the right behaviour and also useless.

mix mishka_cms_core.purge_draft_archival --dry-run
mix mishka_cms_core.purge_draft_archival
mix ash.codegen remove_draft_archival
mix ash.migrate

Running it on a database that never archived, or twice, or after the column is gone, is a clean no-op in each case.

In a release

A release has no Mix, and bin/migrate drops the column unattended — so the purge has to happen before it, through eval:

bin/mishka_cms eval 'MishkaCmsCore.Runtime.DraftArchivalPurge.run()'
bin/migrate