Commit graph

2 commits

Author SHA1 Message Date
Viktor Torstensson
42c3105537
terminal: thread a context into postgresDatabaseExists 2026-06-16 21:45:47 +02:00
Viktor Torstensson
6d2bf233e8
config: block startup on mixed SQL backends
Reject `litd` startup when another SQL database exists than the selected
SQL `databasebackend` choice.

When starting with the `databasebackend` config flag set to `postgres`,
we check whether an `sqlite` database file exists at the default path
and fail startup if it does. When starting with `sqlite`, we instead
check whether `postgres` database configuration has been provided and,
if so, whether a database exists at the configured `postgres`
connection parameters.

This prevents accidental switches between SQL backends. This is
especially important because allowing such a switch would retrigger the
KVDB-to-SQL migration for the newly configured SQL backend. In that
scenario, the data would already have been migrated previously, meaning
the migration source would be stale and could result in outdated data
being imported. Additionally, it would create two divergent copies of
the data across separate SQL backends. Since we do not support
migrations between SQL backends, recovering from such a situation would
not be possible.
2026-06-16 21:45:47 +02:00