# Database command errors

These are the errors of the commands that reach a database: applying
migrations, seeding, and reading or acting on background work. Each
needs a database the command can reach, so their pages show a run
against one.

| Rule | Raised by | What it means |
|---|---|---|
| `ai.usage_unavailable` | `ai usage` | The app's AI usage couldn't be read from its database, because it can't be reached or has no table for it yet |
| `deliveries.not_found` | `deliveries` | The id given to `jadpo deliveries` matches no delivery or schedule run in the database |
| `deliveries.unavailable` | `deliveries` | The app's deliveries couldn't be read from their database, because it can't be reached or has no table for them yet |
| `deliveries.wrong_state` | `deliveries` | A delivery or schedule run was asked to do something its state rules out, such as cancelling one that has already failed |
| `flags.unavailable` | `flags` | The flags' state couldn't be read or changed in their database, because it can't be reached, has no table for them yet, or changed while the command ran |
| `migration.apply_failed` | `migrate apply`, `seed`, `dev`, `test` | Applying the project's migrations to a database stopped at a step that failed |
| `migration.drop_not_accepted` | `check`, `build`, `migrate apply`, `seed`, `dev` | A migration removes data, and no acceptance in the project says a person agreed to it |
| `migration.extension_missing` | `migrate apply`, `seed`, `dev`, `test` | The project's migrations need a PostgreSQL extension, such as pgvector, that the database server doesn't offer or that the role applying them can't create |
| `migration.extension_outdated` | `migrate apply`, `seed`, `dev`, `test` | The database server's PostgreSQL extension, such as pgvector, is older than the project's migrations and queries need |
| `migration.store_diverged` | `migrate apply`, `seed`, `dev` | The migrations a database has applied don't match the project's: one has changed since it ran, the project doesn't have one, or one comes out of order |
| `runs.unavailable` | `runs unfinished` | The app's unfinished runs couldn't be read from their database, because it can't be reached or has no table for them yet |
| `schedules.lease_held` | `schedules run`, `deliveries retry` | A schedule was run by hand while another run of it still holds its lease, so it wasn't run again |
| `schedules.no_tick` | `schedules run`, `deliveries retry` | A schedule was run by hand against a deployment, and no tick of the app picked the run up in time, so nothing ran |
| `schedules.run_failed` | `schedules run`, `deliveries retry` | A schedule run by hand ended in a failure, or its run on the app never ended |
| `schedules.unavailable` | `schedules`, `deliveries retry`, `why` | The app's schedules couldn't be read from their database, because it can't be reached or has no table for them yet |
| `seed.failed` | `seed` | A seed `jadpo seed` ran stopped at a call that failed or faulted, and the calls before it stay in the database |
| `seed.production_refused` | `seed` | A seed was run against a database that isn't on this machine, which may be production |
| `seed.unavailable` | `seed` | The database a seed runs against couldn't be reached, so nothing was run |
