AI security and compliance
Soft delete vs hard delete: which fits regulated software?
Delete removes the row. It also removes your answer to the question "what happened?"
Short answer
In the soft delete vs hard delete debate, regulated software has a clear default: do not destroy records that a request, price, payment or release depends on. Replace delete with suppress, so the record leaves search and everyday screens but keeps every audit event tied to it. Then design a separate, deliberate purge path for data the law or the user requires you to erase. Both are far cheaper to build on day one than to retrofit.
On this page
01Why delete is the wrong default in regulated products
In a regulated workflow, a record is rarely just a record. It is evidence. A transcript request ties together who asked, who approved, what price was set, when payment cleared and when the file was released. An invoice ties a package, a customer, a status and a payment. If any of those rows can disappear, the chain breaks, and the next dispute is decided by memory instead of data. This is part of our larger guide, AI security for SaaS: protect data and pass security reviews.
Health regulation in the U.S. makes the expectation explicit. The HIPAA Security Rule requires mechanisms that record and examine activity in systems holding protected health information, and policies that protect that information from improper alteration or destruction. Other regulated industries have their own versions. The common thread is that you must be able to show what happened, and that records are not changed or destroyed without control.
Hard delete makes both harder. You cannot examine activity on a record that is gone, and an unrestricted delete button is, by definition, uncontrolled destruction.
02Soft delete vs hard delete: suppress, archive and purge
Most products have one "delete" action that is asked to do three jobs. Splitting them is the core design decision.

| Operation | What the user sees | What happens to data | Who can do it |
|---|---|---|---|
| Suppress | The record disappears from search and lists | Record and its history stay; a flag hides it | The record's owner, within their role |
| Archive | The record moves out of active views but can be found and restored | Record stays; status changes; restore is possible | Admins or owners, with a reason |
| Purge | Nothing; the data is gone | Personal or content data is erased; a minimal audit entry may remain | A controlled process, never a casual button |
Suppress is the everyday action. It answers "I do not want this shown" without answering "this never existed". Archive handles lifecycle: closed accounts, retired items, former staff. Purge exists for legal erasure, retention expiry and data the user has the right to have removed, and it should be logged, reviewed and rare.
03The real costs of soft delete, and how to contain them
Soft delete has critics, and they have a point. A well-known engineering essay by Brandur Leach argues that soft deletion is often not worth it: every query has to remember to filter deleted rows, foreign keys stop protecting you, and undelete is rarely used. He suggests moving deleted rows into a separate table instead.
In regulated products we still default to keeping records, but we take those costs seriously:
- Filter in one place. Put the visibility rule in the data access layer or in database views, not in every query. A missed filter is how a suppressed record reappears in search.
- Model state, not a deleted flag. A status such as active, suppressed or archived is clearer than a timestamp named deleted_at, and it fits status-driven workflows.
- Keep the audit log separate. The audit trail should be an append-only record of events, not reconstructed from the current state of rows. Then even a purge leaves a minimal entry that something was removed, when and by whom.
- Plan the purge path. If you keep everything forever, you have a different compliance problem. Decide retention rules early and build the job that applies them.
- Test restore. If archive promises restore, test it like any other feature.
The alternative Brandur describes, a separate table of deleted records, is a reasonable way to implement archive. The point is not which mechanism you pick but that the decision is made before the first customer depends on the history.
04What an audit trail must hold
An audit trail is useful only if it answers questions people actually ask in a dispute or a review. Design it backward from those questions:

- 01
Who acted?
The authenticated user, with their role at that moment, not just an account ID.
- 02
What changed?
The action and the before and after values for the fields that matter.
- 03
On which record?
A stable identifier that ties every event in a lifecycle together, such as one request ID across request, approval, pricing, payment and release.
- 04
When?
Server time, consistently recorded.
- 05
Why, where it matters?
A reason for overrides, suppressions of sensitive records and manual corrections.
Tie the whole lifecycle to one identifier from the start. Retrofitting a lifecycle ID across tables that grew separately is one of the most expensive changes we see in mature products, and it is exactly the kind of foundation work that blocks AI features later. An agent that acts in your product needs the same audit trail a person does. For how that plays out when adding agents, see how to add AI agents to an existing SaaS product without rebuilding it.
05What we see in production
In a national legal marketplace that connects court reporting agencies and attorneys, every step of a transcript order is tied to one request ID: the attorney's request, the agency's review and pricing, payment, fulfillment and release. In the second phase we replaced delete with suppress, expanded the request statuses and added audit events and in-request messaging. Agencies can keep a record out of search without breaking the history of the requests attached to it. Sealed records are suppressed automatically, and protective-order records need extra authorization. Admins have no access to transcript contents, yet the platform still keeps a full audit trail per request.
For an upgrade-package and invoicing platform serving RV dealership groups, we built five roles with access scoped by franchise, invoices that move through statuses such as Pending Financing and paid, and an activity log. Status changes, not deletions, carry the financial story of each deal.
For a fitness technology product spanning gym machine tablets, a member app and an admin portal, admin profiles use soft delete and restore across a gym, branch and super admin hierarchy. Members can delete their own records and accounts after re-entering their password. That split is the pattern in small form: staff records are archived with restore, and personal data the member owns can be erased by the member, deliberately.
In that gym product, soft delete and restore for admin accounts arrived when the client asked for one owner to run several gyms, and member ID numbers are stored encrypted.
None of these was an AI project, and that is the point. The foundations that make AI safe to add later, a lifecycle ID, status-driven records and an audit trail, are ordinary engineering decisions made early.
06A day-one checklist
- 01
Replace the generic delete with suppress, archive and purge, each with its own permission.
- 02
Put visibility filtering in one shared layer.
- 03
Choose one identifier that follows each business lifecycle end to end.
- 04
Write audit events to an append-only store with actor, role, action, record, time and reason.
- 05
Define retention rules and build the purge job before you need it.
- 06
Give users a deliberate, confirmed way to erase data they own.
- 07
Test restore and test that suppressed records stay hidden everywhere, including exports and search.
Frequently asked questions
Does soft delete satisfy a request to erase data?
No. Suppress hides a record from search and everyday screens, but the record and its history stay. Data the law or the user requires you to erase needs a separate purge path: a controlled process that is logged, reviewed and rare. Even then, a minimal audit entry can record that something was removed, when and by whom.
Where should the soft delete filter live?
In one place: the data access layer or database views, not every query. Every query that has to remember to filter deleted rows is a chance for a suppressed record to reappear in search. Then test that suppressed records stay hidden everywhere, including exports and search.
Is a separate table of deleted records a good alternative?
It is a reasonable way to implement archive. Brandur Leach suggests moving deleted rows into a separate table instead of flagging them. The mechanism matters less than the timing: decide how records are suppressed, archived and purged before the first customer depends on the history.
Why does this matter for AI features?
An agent that acts in your product needs the same audit trail a person does. A lifecycle ID, status-driven records and an append-only audit trail are the foundations that make AI safe to add later. Retrofitting a lifecycle ID across tables that grew separately is one of the most expensive changes in mature products.
How Datics helps
Datics specializes in brownfield AI: bringing production AI into the product you already operate, without forcing a rebuild.
Related work
Case studies from our projects on the same subject.
Transcripts U.S.
Government, Legal & Defense · Legal transcript marketplace
Court reporting agencies publish transcript metadata without the file ever leaving their browser
Agencies once uploaded full transcripts to the marketplace; now title page details are read in their own browser, and they confirm what is published.
Coast Technology
Automotive & Dealerships · Package sales and invoicing platform
RV dealers build add-on packages, invoice them and see profit per deal
Advisers needed packages built from inventory and invoiced through financing. Now one platform does both and shows profit per deal.
Inzer
Healthcare & Wellness · Gym floor tablet and member app
Gym members learn each machine and log every set on its shared tablet
Members relied on trainers and handwritten logs. Now the tablet on each machine shows how to use it and logs every set.
More on AI security and compliance
AI security and compliance
AI security for SaaS: protect data and pass security reviews
A practical map of AI security for established SaaS: threats, data governance, permissions, audit trails and how to answer enterprise security reviews.
AI security and compliance
How do you stop AI data leakage through search metadata?
Stop AI data leakage in search by treating metadata as sensitive: classify records, automate high stakes rules, keep people on unclear cases, and audit.
AI security and compliance
LLM security: why treat model output as untrusted input?
A core LLM security rule: treat every model response like input from an unknown user. Parse it, validate it against business rules, then let it through.
AI security and compliance
Which AI disclaimers does a product need?
An AI disclaimer works when it is designed into the feature: say it is AI, that it can be wrong, what happens to data, and where its numbers come from.
AI security and compliance
What enterprise AI security questions do buyers ask?
Enterprise AI security reviews ask where data and models run, who reaches production, what the AI may do alone and how it is logged. Here is how to prepare.
AI security and compliance
How do you enforce tenant isolation beyond database rows?
Tenant isolation beyond database rows means boundaries per field and per role, in caches, files, payments and jobs, so no tenant sees what another owns.
Your customers already expect AI from your product.
Let us make it real without rebuilding what already works.
