Public: anyone can read this; the crew can change it.
A boot on a database the first paint cannot read says which health check fails, and why, in the app's log #207
A boot on a database the first paint can't read now logs which health check fails and the database's own error. Tests in src/health.test.ts pass (4 of 4). I did not run the full suite.
stopped parked by the crew deploy 2169276
2 earlier comments
This pull now logs which health check fails at boot, and it also repairs the database that was failing it.
What the new log line showed. The preview's database was missing deal.closing_time, so the deals check failed. This is the cause of the 503s on #198 and production (#195). Migrations apply by position. The closing time and place columns were inserted mid-list, so a database already past that position never got them. The same thing happened earlier with profile.line.
Fix. I appended two repair migrations to src/db.ts that re-add closing_time and closing_place. migrate already tolerates "duplicate column name", so healthy databases are unaffected. src/migrations.pin.json gains two hashes and no existing pin changed.
Tests.
src/migrations.test.tshas a new test: a database with those columns dropped and its version rewound fails thedealscheck, then passes aftermigrate.- The "before the Profile line" test in
src/migrations.test.tsand the profile test insrc/health.test.tsnow skip the two repair migrations when they build an old database. - Local runs:
src/health,src/migrations,src/db,src/upgrade,src/hold,src/dealsandsrc/servertests, all passing. - There is no
scripts/gate.tsortsconfig.jsonin this clone, so I ran neither the gate nor the type check.
Unchanged from the first push.
failedCheckDetailinsrc/health.ts, withfailedCheckkeeping its signature.- The single boot line on stderr, from a read-only connection.
/healthzstill answers with only the check's name.- No contract cell changes.
To try it. Once this deploys, the preview's /healthz should answer 200. Production recovers the same way once this is merged.
🤖 Generated with Claude Code
The boot log now names the failing health check, and this pull also repairs the databases that were failing it. I ran no deploy and no type check here. The 503 came from migrations inserted mid-list. Databases whose version counter had already passed that position never got those columns. The preview then failed first on deal.closing_time, and next on deadline.lead_days.
What the pull does
- Boot log:
failedCheckDetail(db)insrc/health.tsreturns{name, message} | null, andfailedCheckkeeps its signature. At boot,src/server.tsruns the checks once on a read-only connection. On a failure it writesdeal-clock: health check "<name>" fails at boot: <db message>to stderr. The server still listens, and a healthy boot adds no line. /healthz: it still answers 503 with the check's name only. The error text and SQL never reach the HTTP answer.- Repair migrations in
src/db.ts: the first fix covered onlyclosing_timeandclosing_place. That leftlead_daysfailing, so I appended a repair for every one-lineADD COLUMN(29 in all).migratealready tolerates "duplicate column name", so healthy databases are unaffected.src/migrations.pin.jsononly gains hashes. - Tests:
- src/health.test.ts covers the detail on a dropped deadline.place (names dates and no such column: place) and null on a fresh database.
- src/migrations.test.ts checks that a database missing closing_* and one missing lead_days fail the check, then pass after migrate.
- The two tests that build an old schema skip the repairs (slice(0, -29)). A later append to migrations would break that count, so those slices need adjusting when it changes.
- I ran the health, migrations, db, upgrade, hold, deals and server test files; all pass.
Not done
- The two multi-statement
remindermigrations (party_role,sample) have no repair. Repeating one statement of a script would stop at the first duplicate. - Mid-list
CREATE TABLEandCREATE INDEXstatements have no repair either. I can't see the preview or production database, so if the preview still fails on a missing table, the boot line will name it. - No contract cell changes.
To try it
Boot against a database missing a column the first paint reads and check stderr. After merge, production's /healthz should answer 200.
🤖 Generated with Claude Code
Parked by the crew: the check stayed red through 2 automatic tries
A boot on a database the first paint can't read now logs which health check fails and the database's own error. Tests in
src/health.test.tspass (4 of 4). I did not run the full suite. There is noscripts/gate.tsortsconfig.jsonin this clone, so I skipped the gate script and the type check.bun x tscfetched an unrelated package instead.What changed
src/health.tshas a newfailedCheckDetail(db)that returns{name, message} | null.failedCheckkeeps its signature and now just returns the name from it, so/healthzstill answers 503 with the check's name and nothing more.src/server.ts: after the "listening on" line, theimport.meta.mainblock runs the checks once. If one fails it writes a single line to stderr,deal-clock: health check "<name>" fails at boot: <db message>. The server still listens.src/health.test.tshas a new test. A fresh database givesnull. A database withdeadline.placedropped gives namedatesand a message matchingno such column: place. It fails on main becausefailedCheckDetaildoesn't exist there.Choices
app.db, so it never writes.serve()doesn't expose its database handle, and I left its signature alone.health check could not run at boot: <message>. You didn't ask for this line.To try it
FORGE_APP_DATApointing at a database that lacks a column the first paint reads, and look at stderr./healthzstill returns 503 with only the check's name.I did not run the failing-boot case end to end; the test covers it at the
failedCheckDetaillevel.🤖 Generated with Claude Code
Closes #205