fix(08-03): seed dev user id=1 — global-setup assumes it exists
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:
@@ -208,6 +208,33 @@ jobs:
|
|||||||
- name: Run DB migrations
|
- name: Run DB migrations
|
||||||
run: pnpm --filter @familysync/api db:migrate
|
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).
|
# Build the API before starting it — dist/ is gitignored and does not exist in CI (Pitfall 4).
|
||||||
- name: Build API
|
- name: Build API
|
||||||
run: pnpm --filter @familysync/api build
|
run: pnpm --filter @familysync/api build
|
||||||
|
|||||||
Reference in New Issue
Block a user