Add auth bootstrap and database safeguards

This commit is contained in:
JB
2026-07-24 22:12:52 -04:00
parent 8a0bfd2187
commit b430a291fa
22 changed files with 380 additions and 62 deletions
+26
View File
@@ -33,3 +33,29 @@ Minor alignment fixes, isolated bug fixes, and corrections that do not introduce
or revise a reusable design decision do not require a documentation update.
If uncertain whether a visual change is significant, update the design system.
## Database preservation
Development data is valuable and may be entered by non-technical contributors.
Treat embedded database files as persistent user data, not disposable build
artifacts.
Before deleting, replacing, recreating, renaming, or destructively migrating a
database—and before any major schema change—create a timestamped JSON backup
with `npm run db:backup`.
Database work must follow these rules:
1. Confirm which environment and exact database path are in scope.
2. Stop processes that hold the embedded database lock before backup or restore.
3. Create and verify a JSON backup before destructive work.
4. Never overwrite or delete the only available backup.
5. Keep backups out of Git; they can contain user records and password hashes.
6. Prefer additive, repeatable schema migrations over database recreation.
7. After a restore, run the schema migration and verify record counts and
critical entities before resuming data entry.
8. Report the backup path when completing database-destructive work.
Use `npm run db:restore -- <backup-file>` only with an empty, migrated target
database. The restore script intentionally refuses to merge into a populated
database.