Audit trail
An audit trail is a chronological record of a system's activity that is complete enough to reconstruct who did what, to which record, and when. In a business app it answers the question every dispute starts with, and Meadowstack 2.1 shows it on every record with `AuditTimeline` while your backend keeps the record itself.
By Bohuslav PoláčekChecked
-- The history row for every change, written by the database so no client can
-- forget it. Security definer: people cannot insert these rows themselves.
create function public.requests_history() returns trigger
language plpgsql security definer set search_path = ''
as $$
declare
kind text;
changes text[] := '{}';
begin
if tg_op = 'INSERT' then
kind := 'created';
elsif new.status is distinct from old.status then
kind := case
when new.status = 'submitted' and old.status in ('approved', 'rejected') then 'reopened'
when new.status = 'submitted' then 'submitted'
when new.status = 'draft' then 'withdrawn'
else new.statusWhy it matters in a business app
"Who approved this?" and "when did the amount change?" come up every week in a business that runs on requests, orders and invoices. Without a history the answer is a meeting. With one, it is a line on the record: the person, the change, the time, and the reason when one was required.
A trail is evidence only if it cannot drift from the data. That rules out a log written by the browser after the fact: the entry has to be written where the change is, and nobody may edit it later.
How Meadowstack handles it
What 2.1 does in the interface:
- Every state change in the starter and the demo writes an entry, and every record shows its history with AuditTimeline; a rejection always carries its reason.
- The simulated api writes the entry with the change, the shape your backend should keep.
What the server side needs, from docs/security.md: the entry written in the same transaction as the change, the table append-only (the app's role may insert and read, never update or delete), every change covered, and no secrets or extra personal data in the detail. The Supabase example does exactly that with the trigger above and a history table with no update or delete policy.
Meadowstack 3.0, coming as an update to every licence, adds an audit trail of security events too: sign-ins, permission changes, exports and deletions, with who, what, when and from where. See also the audit trail pattern.
Common mistakes
- History written by the client. A second request that can fail or be skipped is a history that lies.
- An editable history table. If the app's role can update it, so can a bug.
- Logging everything. Passwords, tokens and whole records in the detail turn the history into a leak.
- Prose instead of facts. "Updated" says nothing; the old and the new amount say what happened, the way the Supabase example writes "Amount: old → new".
How people read it
Sources
Questions
What is the difference between an audit trail and application logs?
Logs are for developers and are rotated away; an audit trail is for people and auditors, tied to records, kept as long as the records, and never edited.
Does Meadowstack store the audit trail?
Not in 2.1: it shows the history and writes it in the simulated api, and your backend stores it. The Supabase example shows a history table written by a trigger in the same transaction.
Should an audit trail record reads as well as changes?
Record changes always. Record reads where the data is sensitive or the law asks for it, such as exports of personal data; logging every view of every list is noise.
Two ways
Build it yourself, or have it built
Build it yourself
Build your app on the framework
Get the codebase these apps stand on and build yours with Claude Code, Cursor or Codex.
One payment, lifetime updates
Get the frameworkHave it built
Have us build your app
Tell us how your team works. We plan the app with you and build it on the same framework at a fixed price.
After launch, Care keeps it improving, from €99 a month.
from €1,990
Describe your app