> ## Documentation Index
> Fetch the complete documentation index at: https://docs.oncoeverything.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Data

> The database, its tables, and how migrations run.

## The database

The database is AWS RDS Postgres 17 on a `db.t4g.micro` instance. It has 20 GB of storage, and the storage grows automatically. Storage is encrypted, and deletion protection is on.

Backups run every day. RDS keeps them for 14 days, with point-in-time recovery inside that window. A restore ran on September 18, 2026. See [Monitoring and recovery](https://docs.oncoeverything.com/operations/monitoring.md).

The database is in a private subnet. Only the API's tasks can reach it. To run a query in production, see [Run a command inside AWS](https://docs.oncoeverything.com/operations/monitoring.md#run-a-command-inside-aws).

## Tables

The schema is in `packages/db/src/schema.ts` and uses [Drizzle](https://orm.drizzle.team).

| Area | Tables |
| - | - |
| Accounts | `organizations`, `users`, `sessions`, `accounts`, `verifications` |
| Requests | `requests`, `request_events`, `quotes`, `quote_templates`, `request_deliverables` |
| Catalog | `reports`, `report_files`, `report_terms`, `taxonomy_terms` |
| Access and copies | `report_entitlements`, `report_deliveries`, `report_delivery_opens` |
| Billing | `billing_settings`, `invoices`, `invoice_lines`, `payments`, `billing_events`, `card_purchases`, `stripe_events` |
| Site | `segment_subscribers`, `analytics_events`, `analytics_salts` |

The schema follows these rules:

* **One `requests` table for every form.** The `type` column and the subject columns carry the differences.
* **One `taxonomy_terms` table for every facet**, such as disease states and report types.
* **Event tables are append-only.** Nobody edits or deletes a row in `request_events` or `billing_events`. The admin shows these rows as the history.
* **Request history is permanent.** Database triggers refuse a delete on `requests` and `quotes`, and an edit or delete on `request_events`. Test cleanup lifts this for one transaction with the `oncoeverything.allow_history_delete` setting.
* **No generic item table.** Each catalog has its own typed table.

`docs/architecture/content-model.md` explains these rules in full. Read it before you add a table or a route.

## Migrations

**1. Change the schema**

Edit `packages/db/src/schema.ts`.

**2. Generate the migration**

```bash theme={null}
bun run --cwd packages/db db:generate
```

Commit the new file in `packages/db/migrations`.

**3. Apply it locally**

```bash theme={null}
bun run --cwd packages/db db:migrate
```

**4. Push**

In production the API applies pending migrations when a new task starts, before its port opens. The health check cannot pass until they are done.

> [!WARNING]
>
> A rollback of the API does not undo a migration. Fix a bad migration with a new one that moves forward.

## Directory data

The recruiter, education, podcast and other directory listings are not in the database. `packages/directories` builds them as JSON files from the client's spreadsheets. The web app reads the files at build time.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.