Archiving Onboarding Completion Records After Account Closure
Deleted accounts don't mean their onboarding history should vanish or stay fully queryable forever. Here's how to decide what moves to cold storage and when.
When an account closes, its onboarding step-completion rows don't become useless, but they also stop being something you want sitting in your primary table forever. You might still need them: a support ticket referencing a closed account, a churn analysis that groups completed-vs-abandoned steps by cohort, a compliance request asking what a user saw and did before they left. But every row you keep queryable has a cost — index size, backup time, query planner work on a table that's mostly dead weight — and most of it will never be read again.
The mistake is treating this as a binary: either delete on closure, or keep everything exactly as it was. Neither answers the real question, which is how long a given record needs to answer a query versus how long it just needs to exist somewhere in case someone asks.
Separate "queryable" from "recoverable"
Queryable means your application or an analyst can run a filter against it today — group by step, join against account metadata, aggregate across a cohort — without a manual restore step. Recoverable means the data still exists and can be pulled back, but doing so takes a deliberate action: a restore job, a request to someone who can run one, a day or two of latency. Most onboarding-completion history, once the account is closed, only needs to be recoverable. The exceptions are rows a live process still reads — a shared cohort aggregate that includes closed accounts, for instance, which has to stay queryable even if the underlying per-account rows move.
Draw the line at the record level, not the table level. A closed account's individual step-completion rows can move; a pre-computed aggregate that already folded those rows into a cohort number can stay where it is, because it's a different piece of data with a different lifetime.
What actually moves, and where
Export the closed account's completion rows — step id, account id, completed_at, and any proof fields if you're also doing signature-based verification — to flat files (JSON lines or Parquet, whichever your analytics tooling already reads) in object storage, keyed by account id and closure date. Then delete the rows from the primary table. This is the only step that has to be transactional: write the export, confirm it landed, delete the source. An export that silently failed and a delete that silently ran is how you lose data permanently instead of moving it.
-- one query, run once per closed account, not per row
COPY (
SELECT step_id, account_id, completed_at, metadata
FROM onboarding_steps
WHERE account_id = $1
) TO 's3://archive-bucket/onboarding/2026/account-$1.jsonl'
FORMAT jsonl;
DELETE FROM onboarding_steps WHERE account_id = $1;
Run this on a schedule keyed to account closure, not immediately on the closure event — give it a grace period (a week is a reasonable default, adjust to your own refund or reactivation window) in case the closure gets reversed. Reactivating an account whose onboarding history already left the primary table is a much worse support incident than carrying a few extra rows for a week.
GDPR erasure is a different request, not a bigger version of this
Archival is about cost, not about rights. A GDPR erasure request means the data has to actually stop existing, including in the archive — which is a different operation with its own tombstone pattern (see deleting onboarding progress on a GDPR erasure request). Don't let one piece of code try to serve both purposes: a cost-driven archive job that quietly becomes the compliance deletion path will eventually either over-delete data you still needed, or fail to actually erase something it should have.
What to measure instead of guessing a retention window
There's no universal number for how long closed-account onboarding history needs to stay queryable before cold storage — that depends on your support team's actual lookback window and how far back your churn analysis reaches, and neither of those is something to invent here. What to measure: how far back, in days, your last twenty support tickets about a closed account actually needed to go, and how far back your most recent cohort analysis queried. Those two numbers, not a guess, set your archival threshold. If you don't have that history yet, start logging the age of the oldest record touched by each query that hits the onboarding table, and revisit after a month.
Build the export path before you need it
If you're wiring this up from scratch, decide the export format and storage location before account closures start piling up unarchived — retrofitting an export job onto a table that's already ten million rows of mixed live and dead data is slower than building it against a smaller table now. Start with the embeddable checklist if you haven't yet, and the API docs cover the fields each completion row carries, which is what you'll be exporting.