# Deployment Records

This page explains the deployment info and operation records the CLI sends to the API server on every operation, and how the `dismiss` flag changes.

## When the CLI Reports

| Function | Called | API | On failure |
|---|---|---|---|
| `removePod()` | After `up` clears old containers, at the start of `clear`, after `down` | `POST /api/pod/update/:uid` with body `{"dismiss": 1}` | Ignored |
| `upsertPod()` | At the end of `up` | `POST /api/pod/upsert` | Returns an error; `up` fails |
| `recordPod()` | At the end of every command, and during sync | `POST /api/pod/record/insert` | Ignored |

The CLI always targets `http://localhost:8080`. If the API server is down, `up` reports `failed to upsert pod` at the last step even though the remote containers are already running.

## Record Content

Values of `records.content`:

| Value | Source |
|---|---|
| `sync` | Remote folder was empty; first sync |
| `overwrite` | Overwrite confirmed after the diff preview |
| `up` | `up` finished |
| `clear` | `clear` finished |
| `down` / `ps` / `logs` / `restart` / `exec` / `build` | A passthrough command finished; the value is the command name |

Each record also stores the hostname and first non-loopback IPv4 of the machine running the CLI. `records.pod_id` is resolved from `uid` to `pods.id` and is `NOT NULL`; the `sync` record of a first deployment happens before the `pods` row exists, so the lookup finds nothing and the insert fails silently.

## dismiss State

```mermaid
stateDiagram-v2
    [*] --> Active: up (upsert)
    Active --> Removed: down / clear / cleanup before re-up
    Removed --> Active: up (upsert resets dismiss=0)
    Removed --> [*]
```

`GET /api/pod/list` returns only deployments with `dismiss = 0`. The CLI writes `starting` to `status`, and nothing currently updates it to another value.

## Database Location

| Condition | Path |
|---|---|
| `DB_PATH` set | The value of `DB_PATH` |
| `/.dockerenv` exists | `/data/database.db` |
| Otherwise | `~/.podrun/database.db`; the folder is created when missing |

See [HTTP API](/http-api) for the table schema.
