# `data.erasure_log_required`

An action erases a person, and the application doesn't say where the erasure log is kept, so restoring a backup would bring them back.

Area 15, [Personal data](/docs/personal-data.md); not declinable; the next step is usually the human's.

## Why Jadpo refuses it

Erasing someone removes them from your database, not from its backups.
Restore a backup taken before they were erased and they are back, as if they
had never asked. The erasure log is what prevents that: each erasure leaves an
entry, and the app erases again anyone logged who is still there every time it
starts.

The log has to survive the restore, so it can't live in a person's own
database, and only you know what else your app has. Jadpo won't guess, and
won't let an erasure go without one.

## What it looks like

app.jadpo:

```jadpo
application {}
```


domains/accounts/actions/close_account.jadpo:

```jadpo
use accounts/entities { User, UserNotFound }

/// Erases someone.
action close_account(id: User.id) fails UserNotFound -> Unit {
    attempt User.erase(id)
}
```

```text
error: Erasing a `User` needs an erasure log, and the application names none
 --> domains/accounts/actions/close_account.jadpo:5:13
  |
5 |     attempt User.erase(id)
  |             ^^^^^^^^^^ leaves an entry in the log
  reason: Restoring a backup would bring back everyone erased since it was taken. The log is what erases them again as the app starts, so it is kept where the restore can't take it back: a database that holds no person's records, or a store of files.
  next: Add `privacy: { erasure_log: { store: <connection> } }` to `application { }`, naming a connection for it (human)
  rule: data.erasure_log_required
  help: https://jadpo.dev/docs/errors/data.erasure_log_required

check failed: 1 error, 3 files
```

`(human)` at the end of the `next:` line tells your coding agent to stop
and ask you which fix you want, because the choice is yours to make: it
decides what you have to run and back up.

## How to fix it

The question is where a log you can't lose should live: it has to outlast a
restore of the database your people are in.

**If you can run a second database,** name one that holds no person's records.
It needs no entities of its own. In `app.jadpo`:

```jadpo
application {
    connections: {
        main: {
            driver: Driver.postgres
        }
        erasures: {
            driver: Driver.postgres
        }
    }
    privacy: {
        erasure_log: {
            store: erasures
        }
    }
}
```



Each erasure now leaves an entry there, and restoring the main database leaves
the log as it was.

**If the app runs on one server with a disk of its own,** name a store of files.
In `app.jadpo`:

```jadpo
application {
    connections: {
        main: {
            driver: Driver.postgres
        }
        erasures: {
            driver: Driver.disk
            path: "/var/lib/app/erasures"
        }
    }
    privacy: {
        erasure_log: {
            store: erasures
        }
    }
}
```



Each person erased is now a file in that folder. A Worker has no disk, so it
keeps the log in a database or in a `Driver.s3` store of files.

## Related

- [What erasure doesn't rewrite](/docs/erasure-after-the-commit.md#what-erasure-doesnt-rewrite)
- [`data.erasure_log_store`](/docs/errors/data.erasure_log_store.md)
