* fix: add id-token write permission and fix invalid inputs in GC workflow The claude-code-action@v1 uses OIDC for OAuth token auth, which requires id-token: write in workflow permissions. Without it ACTIONS_ID_TOKEN_REQUEST_URL is not set and the action fails after 3 retry attempts. Also moves model and allowed_tools from unsupported top-level inputs into claude_args where they are valid CLI flags for claude-code-action@v1. * fix(gc): show agent output and explicit dry-run issue posting - Add show_full_output: true so Claude responses appear in CI logs - Replace vague dry-run instruction with explicit gh issue create/comment commands so output has a concrete destination (tracking issue) - Bake DRY_RUN value into prompt at workflow-expansion time to eliminate ambiguity about env var reading * docs: mark cloud-auth-architecture.md as superseded by ADR-003 * fix(docker): guard community seeder cd and add ENCRYPTION_MASTER_KEY default - Wrap `cd $SEEDERS_DIR/community` in an existence check so the data-engine container no longer crashes when local-seeders/community/ is an empty or uncloned nested git repo. The container was entering Docker's exponential-backoff restart loop (2s→60s) on every boot. - Add ENCRYPTION_MASTER_KEY to the wwv environment block with a local-dev fallback, matching the AUTH_SECRET pattern. Without it the Next.js instrumentation hook throws at startup and the app never serves a request. * fix(docker): auto-baseline P3005 when schema exists without migration history Wraps prisma migrate deploy in the container entrypoint to detect P3005 (schema populated by pnpm dev / prisma db push before the Docker stack was started). When detected, runs prisma migrate diff to confirm zero schema drift, then marks each migration as applied via migrate resolve --applied and retries deploy. Exits with a clear error if drift is found. Also documents the auto-baseline behavior in database-migrations.md and fixes duplicate section numbering in that file.
2.3 KiB
description, paths
| description | paths | |
|---|---|---|
| Rules for safe Prisma schema changes, defensive migrations, and PostgreSQL DDL operations. |
|
Database Migrations & Schema Modification Rules
1. Defensive Migrations
When making database schema changes, you must ensure that generated migrations are resilient against environmental discrepancies.
- Review Generated SQL: Always review the
.sqlfiles generated bynpx prisma migrate dev. - Add "IF EXISTS" clauses: Prisma can sometimes produce brittle drop statements (
DROP INDEX "my_index"). To prevent migrations from crashing if a state desynchronization occurs, manually edit the migration file to useDROP INDEX IF EXISTS "my_index";orDROP TABLE IF EXISTS "table_name";. - Data Preservation: When dropping columns or renaming, carefully review the migration to ensure data is correctly mapped. In PostgreSQL, ensure that cascaded drops don't accidentally remove required data.
2. P3005 Auto-Baseline (Handled in docker-entrypoint.sh)
docker-entrypoint.sh automatically recovers from Prisma P3005 ("schema not empty, no migration history"). This happens when pnpm dev (which runs prisma db push) populates the database before the Docker stack is started.
The entrypoint only auto-baselines when both conditions hold:
- The error is exactly P3005.
prisma migrate diffreports zero schema drift between the live DB andprisma/schema.prisma.
If drift is detected the container exits with a clear error message directing you to pnpm db:reset.
Never add manual
migrate resolve --appliedcalls unless you are outside the container and have independently verified the above two conditions. The entrypoint already handles the common case.
3. Managing Failed Migrations
If a migration fails in production:
- Never blindly mark as resolved: Do not run
prisma migrate resolve --applied <migration_name>unless you have explicitly verified that the database schema precisely matches the expected state. - If you use
resolve --applied, Prisma will permanently skip that migration in the future, leaving your database structurally out of sync with your Prisma Client.
4. Backups Before DDL
Never perform direct DDL operations (ALTER, DROP, CREATE) on a production database without first confirming an automated backup exists, or manually taking a pg_dump backup of the database.