d92b8d1e6a
A site is sometimes run live to train operators/admins; afterwards the demo data must go without an obvious self-serve button (the operator must not be able to wipe history). Adds packages/db/scripts/reset-db.mjs, exposed as `pnpm db:reset` (dev) and run via `docker exec ... node node_modules/@parking/db/scripts/reset-db.mjs` on the booth (no pnpm there). Category flags (combinable): --financial (ledger + telemetry + snapshots + subscription instances + blocklist; keeps users/devices/config/tariffs/plans), --config, --users, --all. Shifts/cash/payments live as event types inside the hash-chained ledger_events, so --financial truncates the whole signed ledger back to empty (re-seed starts a new chain under the SAME EVENT_SIGNING_KEY — keys untouched). Two safety gates: RESET_ALLOWED=1 env (a real booth never sets it) + typed DB-filename confirmation (--yes skips for CI). Single transaction + VACUUM. Verified on throwaway dev-DB copies: both gates refuse correctly; each flag wipes/keeps the right tables; the real dev DB is never touched. Claude-Session: https://claude.ai/code/session_01Xcm6ikLgGoCxxHrxtjkk5V
43 lines
1.1 KiB
JSON
43 lines
1.1 KiB
JSON
{
|
|
"name": "@parking/db",
|
|
"version": "0.0.0",
|
|
"private": true,
|
|
"type": "module",
|
|
"exports": {
|
|
".": {
|
|
"types": "./dist/index.d.ts",
|
|
"default": "./dist/index.js"
|
|
},
|
|
"./schema": {
|
|
"types": "./dist/schema.d.ts",
|
|
"default": "./dist/schema.js"
|
|
},
|
|
"./testing": {
|
|
"types": "./dist/testing.d.ts",
|
|
"default": "./dist/testing.js"
|
|
}
|
|
},
|
|
"main": "./dist/index.js",
|
|
"types": "./dist/index.d.ts",
|
|
"scripts": {
|
|
"build": "tsc -b",
|
|
"dev": "tsc -b --watch",
|
|
"typecheck": "tsc --noEmit",
|
|
"lint": "tsc --noEmit",
|
|
"db:generate": "drizzle-kit generate",
|
|
"db:migrate": "DATABASE_URL=\"${DATABASE_URL:-../../apps/server/parking.sqlite}\" drizzle-kit migrate",
|
|
"db:migrate:runtime": "node scripts/migrate-runtime.mjs",
|
|
"db:reset": "DATABASE_URL=\"${DATABASE_URL:-../../apps/server/parking.sqlite}\" node scripts/reset-db.mjs"
|
|
},
|
|
"dependencies": {
|
|
"@parking/shared": "workspace:*",
|
|
"better-sqlite3": "12.10.1",
|
|
"drizzle-orm": "0.45.2"
|
|
},
|
|
"devDependencies": {
|
|
"@types/better-sqlite3": "7.6.13",
|
|
"drizzle-kit": "0.31.10",
|
|
"typescript": "6.0.3"
|
|
}
|
|
}
|