fix(08-03): seed dev user id=1 — global-setup assumes it exists
CI / fast-checks (pull_request) Successful in 48s
CI / api (pull_request) Successful in 56s
CI / harness (pull_request) Failing after 2m0s

global-setup.ts seeds calendars/lists/events for user_id=1 but never creates
the user (DEV_AUTH_BYPASS injects DEV_USER in-memory only). On a fresh CI DB the
calendars INSERT IGNORE is silently skipped on the users FK → calendar 10 missing
→ calendar_events insert fails FK. Add an idempotent users(id=1) seed after
migrate (validated locally: full insert chain passes). No harness files changed.
This commit is contained in:
Lucas Berger
2026-06-11 15:36:52 -04:00
parent 73897407c7
commit e486c6be9f
+27
View File
@@ -208,6 +208,33 @@ jobs:
- name: Run DB migrations
run: pnpm --filter @familysync/api db:migrate
# Seed the dev user (id=1). DEV_AUTH_BYPASS injects DEV_USER (id=1) into the request
# context in-memory only — it never writes a users row (devBypass.ts). global-setup.ts
# seeds calendars/lists/events for user_id=1 but ASSUMES that user row already exists
# (true on the dev DB, false on a fresh CI DB): without it the calendars INSERT IGNORE is
# silently skipped on the users FK, so calendar 10 is missing and the calendar_events
# insert fails its FK. Idempotent INSERT IGNORE; matches DEV_USER (oidc dev/dev-user, #4A90D9).
- name: Seed dev user (id=1)
run: |
node --input-type=commonjs - <<'EOF'
const mysql = require('mysql2/promise');
(async () => {
const conn = await mysql.createConnection({
host: process.env.DB_HOST,
port: Number(process.env.DB_PORT ?? 3306),
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
});
await conn.execute(
"INSERT IGNORE INTO users (id, oidc_iss, oidc_sub, display_name, color) VALUES (1, 'dev', 'dev-user', 'Dev User', '#4A90D9')",
);
console.log('seeded dev user id=1');
await conn.end();
})();
EOF
working-directory: apps/pwa
# Build the API before starting it — dist/ is gitignored and does not exist in CI (Pitfall 4).
- name: Build API
run: pnpm --filter @familysync/api build