From 2d9bb15d4ca5a1c593ac337a1bd07440e8b55619 Mon Sep 17 00:00:00 2001 From: Julian Cuni Date: Mon, 7 Sep 2026 14:37:49 +0200 Subject: [PATCH] =?UTF-8?q?fix(db):=20reset-db=20categorises=20the=20Car?= =?UTF-8?q?=20Wash=20tables=20and=20role=5Fjobs=20=E2=80=94=20the=20drift?= =?UTF-8?q?=20guard=20refused=20every=20reset=20on=20a=20booth=20carrying?= =?UTF-8?q?=20them?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Claude-Session: https://claude.ai/code/session_01FWncR69HgGPuei1dLrW3cU --- packages/db/scripts/reset-db.mjs | 13 ++++++++++++- wiki/concepts/local-dev-workflow.md | 6 +++--- wiki/decisions/appliance-provisioning.md | 8 ++++++++ wiki/log.md | 9 +++++++++ 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/packages/db/scripts/reset-db.mjs b/packages/db/scripts/reset-db.mjs index 9425c8d..11cd403 100644 --- a/packages/db/scripts/reset-db.mjs +++ b/packages/db/scripts/reset-db.mjs @@ -51,6 +51,10 @@ const CATEGORIES = { "subscription_credentials", "subscriptions", "blocklist", + // Car Wash (venue module): orders are money history (settled against ledger events); + // the review outbox is a delivery queue of crops + choices — both go with the ledger. + "carwash_review_outbox", + "carwash_orders", ], config: [ "site_config", @@ -65,8 +69,15 @@ const CATEGORIES = { // whose user is gone grants nothing. "validation_program_users", "validation_programs", + // Car Wash master data: prices reference categories + services (child first); the + // module's site-level config (pay-at, vision threshold) is config like site_config. + "carwash_prices", + "carwash_categories", + "carwash_services", + "carwash_config", ], - users: ["sessions", "role_permissions", "users", "roles"], + // role_jobs = which jobs a role follows (child of roles). + users: ["sessions", "role_permissions", "role_jobs", "users", "roles"], diagnostics: ["app_logs"], }; diff --git a/wiki/concepts/local-dev-workflow.md b/wiki/concepts/local-dev-workflow.md index 901bf04..d2b7b29 100644 --- a/wiki/concepts/local-dev-workflow.md +++ b/wiki/concepts/local-dev-workflow.md @@ -70,9 +70,9 @@ RESET_ALLOWED=1 DATABASE_URL=/path node packages/db/scripts/reset-db.mjs --all | Flag | Wipes | Keeps | | --- | --- | --- | -| `--financial` | `ledger_events` (entry/exit/payment/void/shift/cash/anomaly), `device_events`, `snapshots`, subscription **instances** + credentials/plates, `blocklist` | users, devices, config, tariffs, subscription **plans** | -| `--config` | `site_config`, `devices`, `setup_state` (→ re-runs first-run setup), tariffs + versions + **drafts**, subscription plans | everything else | -| `--users` | `users`, `roles`, `role_permissions`, auth `sessions` | everything else | +| `--financial` | `ledger_events` (entry/exit/payment/void/shift/cash/anomaly), `device_events`, `snapshots`, subscription **instances** + credentials/plates, `blocklist`, `carwash_orders`, `carwash_review_outbox` | users, devices, config, tariffs, subscription **plans**, Car Wash master data | +| `--config` | `site_config`, `devices`, `setup_state` (→ re-runs first-run setup), tariffs + versions + **drafts**, subscription plans, validation programs, `carwash_prices/categories/services/config` | everything else | +| `--users` | `users`, `roles`, `role_permissions`, `role_jobs`, auth `sessions` | everything else | | `--diagnostics` | `app_logs` (the unsigned [[app-logs]] store behind `/setup/logs`) | everything else | | `--all` | every table (blank slate) | — | diff --git a/wiki/decisions/appliance-provisioning.md b/wiki/decisions/appliance-provisioning.md index d213879..7a4e930 100644 --- a/wiki/decisions/appliance-provisioning.md +++ b/wiki/decisions/appliance-provisioning.md @@ -415,6 +415,14 @@ docker exec -it \ > it) **and** you type the DB filename to confirm (`parking.sqlite`; `--yes` skips that for scripted > setup only). It is a **training/demo** tool — never run on a production booth's data. +> **Drift caught 2026-09-07:** the Car Wash module (six `carwash_*` tables) and `role_jobs` had +> landed without a category, so the guard refused every reset on a booth carrying them. Categorised +> now — orders + the review outbox under `--financial`, prices/categories/services/config under +> `--config`, `role_jobs` under `--users` — and verified `--all` on a freshly migrated DB. The script +> ships **inside the server image**, so a booth runs the fixed version only from the next deployed +> tag; until then `docker cp` the file from the repo into the container at +> `/app/node_modules/@parking/db/scripts/reset-db.mjs` and run the same command. + After `--users`/`--all` (users cleared), re-seed the first admin exactly as in §7b (`docker exec … node scripts/seed-admin.mjs`) so someone can log back in. Since 2026-07-06 the seed script **self-heals the built-in `admin` role row** that this reset also wipes — before that fix the diff --git a/wiki/log.md b/wiki/log.md index 1d33b76..594f880 100644 --- a/wiki/log.md +++ b/wiki/log.md @@ -3144,6 +3144,15 @@ run; the Quadro FX 3800 is unusable (cc 1.3), the HD P530 irrelevant, the Xeon E compose seam drops the GPU reservation; cloud GPU rejected (crops stay on premises). Linked from [[opencv-anpr-service]], [[vision-review-outbox]], index. User: "No build just yet." +## [2026-09-07] fix | reset-db drift — Car Wash tables and role_jobs were uncategorised +User asked for "the command to reset everything in the booth pc". The documented command +([[appliance-provisioning]] §7d, `docker exec … reset-db.mjs --all`) would have been refused on +park-2: the drift guard found `carwash_*` (six tables) and `role_jobs` outside every category. +Categorised (orders + review outbox → financial; prices/categories/services/config → config; +role_jobs → users), `--all` verified on a freshly migrated DB. The script ships in the server +image — fixed on the booth from the next deployed tag, or by `docker cp` until then. Table +rows updated on [[local-dev-workflow]]. + ## [2026-09-07] decision | Desktop v0.2.0 — a minor bump, not a patch User: "Do you think we are ready for version 0.2.0? The actual version is 0.1.7." Yes: v0.1.x were all shell fixes; the bundled SPA now carries the module registry, Car Wash + per-till