migrate database from SQLite to PostgreSQL; add PostgreSQL adapter and migration script

This commit is contained in:
ImBenji
2026-04-27 14:33:46 +01:00
parent 653a58b3d8
commit b4df02da0d
13 changed files with 1978 additions and 6 deletions
+11
View File
@@ -2,6 +2,17 @@
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: