Commit Graph

4 Commits (8456e45206f5c7656c4d24498a9533808cf8eb2c)

Author SHA1 Message Date
Thomas Joise 0adce5844b fix(backup): resolve the production database the way the server does
`npm run backup` ran scripts/backup.mjs, which read process.env.DATABASE_URL
directly and exited when it was unset. On the production box DATABASE_URL is NOT
exported -- the connection is resolved (D19) -- so the backup command could never
reach the real data.

The dump now lives in apps/hq (src/backup.ts + a thin scripts/backup.ts CLI, the
same split the other maintenance scripts use, so it is typechecked and unit
tested) and resolves its target through the shared resolveDbUrl. It logs the
resolved host/db -- never the password -- before pg_dump runs, and a SQLite
outcome is a loud error naming backup-hq.sh instead of a dump of nothing.
Behaviour otherwise unchanged: -Fc dump under ./backups (or HQ_BACKUP_DIR),
rotation to the newest HQ_BACKUP_KEEP (default 14), same pg_dump discovery.

The .mjs entry could not import the TS resolver, and duplicating the resolution
would have re-introduced the copy of the production connection string that
6f50799 deliberately removed -- hence the move to TS. `npm run backup` is
unchanged for the operator; prod already runs `npx tsx apps/hq/scripts/...` for
maintenance (see DEPLOY-HQ.md), so tsx is on the box.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 day ago
Thomas Joise 62eb937012 feat(d33): database backup script (pg_dump + rotation)
scripts/backup.mjs (npm run backup): pg_dump the DB to a timestamped compressed
pg_restore-able file under ./backups (gitignored), keep newest HQ_BACKUP_KEEP (14).
Locates pg_dump on PATH or the Windows PostgreSQL install dir. Verified against live
data: 304 KB dump, 32 tables, valid archive. Backups hold plaintext creds (D32) so
backups/ is gitignored + documented as access-controlled. Pending: schedule + off-box
copy + DB password out of server.ts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
3 days ago
Thomas Joise 7e1c93cee0 Split: make this the standalone HQ project (remove Store)
This repo keeps its 60-commit HQ history and becomes independent of the Store
product. Removed the Store apps (pos, store-server, backoffice), the Store-only
packages (config, scanning, search-core, printing — printing was already a dead
dependency in hq-web), and the Store planning docs.

Shared packages are forked and trimmed to exactly what HQ uses: domain keeps
ids/money/business-day/doc-series/gstin/documents; auth keeps pin; billing-engine
keeps compute/tax. Store-only tests for the removed modules were dropped, and
auth.test.ts was trimmed to its PIN blocks. Package renamed sims-hq; root
tsconfig/vitest paths narrowed to the four kept packages.

Verified independently: npm install + typecheck clean, 177 tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5 days ago
Thomas Joise 7bc7976e4e chore: root typecheck now fans out to every workspace's own tsconfig
Closes the gap where app-level type errors escaped the standard gate
(root tsconfig covers packages/* only; apps each have their own).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2 weeks ago