Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

feat(server): name the database in the start banner

Maurice9dc80760f786
diff --git a/server/src/index.ts b/server/src/index.ts
index 5accbe2bb..2bfe4aebc 100644
--- a/server/src/index.ts
+++ b/server/src/index.ts
@@ -14,8 +14,9 @@ import { resolveDataPaths } from './app-config/data-paths';
// keeping the require after the restore keeps that true by construction.
import type * as Bootstrap from './bootstrap';
import { resolveDbPath } from './db/db-path';
-import { postgresTarget } from './db/engine';
+import { postgresTarget, type DatabaseEngine } from './db/engine';
import { flushLogFileSync, logError } from './nest/audit/audit-log.logger';
+import { DATABASE_ENGINE } from './nest/database/database-engine.module';
import type { DatabaseLifecycle } from './nest/database/database-lifecycle.service';
import { ReadinessService } from './nest/health/readiness.service';
import { createFatalHandler } from './shutdown';
@@ -61,6 +62,10 @@ const onListen = () => {
` Container Port: ${PORT}`,
` App URL: ${appUrl}`,
` Environment: ${env.app.nodeEnv || 'development'}`,
+ // Which database this process runs on, so an operator sees after a move
+ // to Postgres (or back) that the start picked the engine they meant. The
+ // engine's own description masks a password in the URL.
+ ...(databaseLabel ? [` Database: ${databaseLabel}`] : []),
` Timezone: ${tz}`,
` Origins: ${origins}`,
` Log level: ${LOG_LVL}`,
@@ -103,6 +108,7 @@ const onListen = () => {
let server: http.Server;
let nestApp: INestApplication;
let database: DatabaseLifecycle | undefined;
+let databaseLabel: string | undefined;
// Strangler toggle: prefixes served by Nest (env-overridable, instant rollback).
async function bootstrap(): Promise<void> {
@@ -114,6 +120,7 @@ async function bootstrap(): Promise<void> {
const { buildApp, getHttpServer, DatabaseLifecycle: Lifecycle } = require('./bootstrap') as typeof Bootstrap;
nestApp = await buildApp();
database = nestApp.get(Lifecycle);
+ databaseLabel = nestApp.get<DatabaseEngine>(DATABASE_ENGINE).describe();
if (restore.restored) await finishFirstBootRestore(nestApp, restore);
// The server buildApp created and bound /ws to. Creating a second one here
// would serve the REST API fine and leave the gateway attached to a socket
diff --git a/wiki/Database-Postgres.md b/wiki/Database-Postgres.md
index fdefb61b7..118474bb1 100644
--- a/wiki/Database-Postgres.md
+++ b/wiki/Database-Postgres.md
@@ -184,7 +184,7 @@ Change those values in the plugin's `plugin.db`, through the plugin or with the
It reads `data/travel.db` and `data/plugins-data`, and writes into the database `TREK_DB_URL` names. For a SQLite file elsewhere in the container, add `--from=/app/data/<file>`; to drop NUL characters from TREK's data, add `--drop-nul` (see above). A refusal or an error says what to fix and leaves the Postgres database empty, so you can run the command again.
6. **Start TREK**: `docker compose -f docker-compose.postgres.yml up -d`.
-7. **Check**: the log reports the Postgres engine and no schema creation. Sign in, open a few trips, open a file and a photo, and look at your plugins.
+7. **Check**: the start banner in the log shows `Database: Postgres postgres://trek:***@db:5432/trek`, and the log shows no schema creation. Sign in, open a few trips, open a file and a photo, and look at your plugins.
Outside Docker, run `npm run db:move-to-postgres` in the server directory, with `TREK_DB_URL` set in the environment or in the server's `.env` file, and `--from=<file>` when the SQLite file is not the server's `data/travel.db`. `--help` prints the options.
@@ -273,7 +273,7 @@ Supabase runs PostgreSQL and can host TREK's database. The checklist below has b
Run it against a throwaway database before an install relies on this page. On Supabase, steps 1 to 6 have been run over the direct connection, and step 7 by marking the last applied migration as pending instead of starting an older image; step 8 and the session pooler have not.
1. Create an empty database and a non-superuser role that owns it. Set `TREK_DB_URL` with a verifying `sslmode` (on Supabase, `verify-full` with `sslrootcert`), or with the server's own setting otherwise.
-2. Start one TREK process. Confirm the log reports the Postgres engine, the schema is created, and the admin account exists.
+2. Start one TREK process. Confirm the start banner names the Postgres database (`Database: Postgres ...`), the schema is created, and the admin account exists.
3. Sign in, create a trip, and confirm it appears after a page reload.
4. Create a backup from the Backup tab. Confirm the archive holds `travel.pgdump` and no `travel.db`.
5. Restore that backup from the Backup tab. Confirm the trip is still there, and that `data/pre-restore-<time>.pgdump` exists.