mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 11:06:06 +00:00
7065f87dc0
The rotation ran on the SQLite file only and refused when TREK_DB_URL was set. Its statements now go through a small store per engine: better-sqlite3 for the file, unchanged, and on Postgres the server's own MikroORM connection, in one transaction that takes the engine's write lock first. The Postgres path checks that it reaches a database holding TREK's tables and that the data directory is writable before it asks for a key, writes a pg_dump copy before it changes anything, refuses DB_PATH or TREK_DB_FILE beside the URL, and reads the jsonb addon config the driver hands back parsed. The SQLite transaction is now BEGIN IMMEDIATE, since better-sqlite3 takes no async function.