22 lines
1.3 KiB
Markdown
22 lines
1.3 KiB
Markdown
# Production Database
|
|
|
|
Never run direct database operations (inserts, updates, deletes, schema changes) against the local SQLite files (e.g. intelligence.sqlite, archive.sqlite). These are local copies and do not affect the production database. All data changes must go through code that runs in production — seed functions, migration scripts, workers, etc.
|
|
|
|
# Remote Database Queries
|
|
|
|
To query the remote production database, POST to `https://duriin.imbenji.net/admin/api/sql` with HTTP Basic Auth (credentials in config.json at `admin.username` / `admin.password`). Use the field names `sql` and `database` (`"archive"` or `"intelligence"`):
|
|
|
|
```
|
|
POST /admin/api/sql
|
|
{ "sql": "SELECT ...", "database": "intelligence" }
|
|
```
|
|
|
|
Note: SQLite syntax only — no `LEFT()`, use `substr()` instead. Response shape: `{"results": [{"rows": [...]}], "elapsed": N}`.
|
|
|
|
# Database Policy
|
|
|
|
When making any changes to the database schema or data, a strictly no data loss policy must be followed. This means:
|
|
- Never DROP columns, tables, or indexes that contain data without first migrating that data elsewhere
|
|
- All schema changes must be additive or safe migrations (e.g. ADD COLUMN, rename via copy+verify+drop)
|
|
- Always backup or verify row counts before and after any bulk UPDATE or DELETE
|
|
- Destructive operations require explicit user confirmation before executing
|