The Unit suite starts with a freshly-dropped test database and does
not create a $db global, so:
- customer_invoice_email_schema_bootstrap::ensureSchema() short-
circuited and never created the users table.
- runSchemaCheck had nothing to inspect and reported ok=false.
Wire up a real mysqli connection at file load time using the same
CONFIG_DB_* env vars the rest of the CI suite exports, then have
beforeEach run the bootstrap and create the bare-minimum invoices /
bookings tables that runSchemaCheck verifies. This keeps the test
self-contained inside the Unit suite without changing the
production code or the production schema.
Refs: api#383, TRU-77
Closes the 'Unknown column invoice_email in SELECT' production failure
mode (TRU-77) by:
- New GET /admin/schema-check endpoint — returns 503 with explicit
list of missing columns if any are absent (instead of a generic 500)
- scripts/run-schema-bootstraps.php — auto-discovers and runs every
*_schema_bootstrap class on the live database (additive, idempotent)
- scripts/schema-health-check.php — CLI tool for the same check, used
by deploy pipelines
- New Pest contract test SchemaHealthCheckTest — verifies the test DB
has every required users column and the schema-check endpoint works
- deploy.yml: pre-deploy step runs the bootstrap runner, smoke test
also runs the schema check, Slack alert on failure