fix(db): refuse a Postgres boot that would leave a SQLite install behind

Setting TREK_DB_URL on an existing SQLite install booted a new, empty
instance beside its data. The Postgres bootstrap now refuses an empty
database, or a migrated one without a single account, while the data
directory's travel.db holds accounts, and names the move command. A file
that cannot be read counts as holding them. TREK_DB_IGNORE_SQLITE_FILE=true
starts anyway, with a warning; the file is opened read-only and only when
the database holds no TREK data.
This commit is contained in:
Maurice
2026-11-17 13:41:12 +01:00
parent a6bc71787e
commit d177227519
10 changed files with 426 additions and 10 deletions
+6 -1
View File
@@ -135,7 +135,12 @@ async function bootstrapBefore(url: string, before: readonly string[]): Promise<
migrations: { ...config.migrations, silent: true, migrationsList: await loadMigrations(before) },
});
try {
await bootstrapPostgresSchema(orm, { ...defaultPostgresBootstrapDeps(url), safetyNet: NO_SAFETY_NET });
await bootstrapPostgresSchema(orm, {
...defaultPostgresBootstrapDeps(url),
safetyNet: NO_SAFETY_NET,
// A scratch database of its own: a SQLite install in the developer's data directory is beside the point.
sqliteLeftBehind: () => null,
});
} finally {
await orm.close(true);
}