mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 11:06:06 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user