Files
summercms/.planning/tmp/plan-pre-schema-gate.md

2.6 KiB

Schema Push Detection Gate

Detects schema-relevant files in the phase scope and injects a mandatory [BLOCKING] schema push task into the plan. Prevents false-positive verification where build/types pass because TypeScript types come from config, not the live database.

Check if any files in the phase scope match schema patterns:

PHASE_SECTION=$(gsd_run query roadmap.get-phase "${PHASE}" --pick section 2>/dev/null)

Scan PHASE_SECTION, CONTEXT.md (if loaded), and RESEARCH.md (if exists) for file paths matching these ORM patterns:

ORM File Patterns
Payload CMS src/collections/**/*.ts, src/globals/**/*.ts
Prisma prisma/schema.prisma, prisma/schema/*.prisma
Drizzle drizzle/schema.ts, src/db/schema.ts, drizzle/*.ts
Supabase supabase/migrations/*.sql
TypeORM src/entities/**/*.ts, src/migrations/**/*.ts

Also check if any existing PLAN.md files for this phase already reference these file patterns in files_modified.

If schema-relevant files detected:

Set SCHEMA_PUSH_REQUIRED=true and SCHEMA_ORM={detected_orm}.

Determine the push command for the detected ORM:

ORM Push Command Non-TTY Workaround
Payload CMS npx payload migrate CI=true PAYLOAD_MIGRATING=true npx payload migrate
Prisma npx prisma db push npx prisma db push --accept-data-loss (if destructive)
Drizzle npx drizzle-kit push npx drizzle-kit push
Supabase supabase db push Set SUPABASE_ACCESS_TOKEN env var
TypeORM npx typeorm migration:run npx typeorm migration:run -d src/data-source.ts

Inject the following into the planner prompt (step 8) as an additional constraint:

<schema_push_requirement>
**[BLOCKING] Schema Push Required**

This phase modifies schema-relevant files ({detected_files}). The planner MUST include
a `[BLOCKING]` task that runs the database schema push command AFTER all schema file
modifications are complete but BEFORE verification.

- ORM detected: {SCHEMA_ORM}
- Push command: {push_command}
- Non-TTY workaround: {env_hint}
- If push requires interactive prompts that cannot be suppressed, flag the task for
  manual intervention with `autonomous: false`

This task is mandatory — the phase CANNOT pass verification without it. Build and
type checks will pass without the push (types come from config, not the live database),
creating a false-positive verification state.
</schema_push_requirement>

Display: Schema files detected ({SCHEMA_ORM}) — [BLOCKING] push task will be injected into plans

If no schema-relevant files detected: Skip silently.