# Easy database setup

This edition uses **Cloudflare D1 Auto Schema Mode**.

## The only required database setting

Create one D1 database and bind it to the Pages project with the exact variable name:

```text
DB
```

No SQL import, migration command, table creation, connection string, password, or database URL is required.

## Dashboard method

1. Open Cloudflare Dashboard.
2. Go to **Storage & Databases → D1 SQL Database**.
3. Create a database named `roberto-devops-db`.
4. Open **Workers & Pages → your DevOps project → Settings → Bindings**.
5. Add a **D1 database** binding.
6. Set **Variable name** to `DB`.
7. Select `roberto-devops-db`.
8. Redeploy the ZIP.
9. Open `/database-setup.html` and press **Check connection**.

The Worker runs `CREATE TABLE IF NOT EXISTS` automatically and safely on first use.

## Verification endpoints

```text
/api/health
/api/database/status
/api/database/setup
/api/database/export
```

A healthy status returns:

```json
{
  "connected": true,
  "initialized": true,
  "mode": "cloudflare-d1-auto",
  "auto_schema": true
}
```

## What the database stores

- Validated GitHub webhook delivery events.
- Workflow dispatch audit records.
- Internal schema metadata.

GitHub Actions, Helm and Argo CD functionality remains available even when D1 is not configured; only persistent audit history is disabled.
