Skip to content

Keep dev schema push off; fix seeding - #167

Open
anthonysantiago-eng wants to merge 2 commits into
mainfrom
docs/local-db-setup
Open

anthonysantiago-eng wants to merge 2 commits into
mainfrom
docs/local-db-setup

Conversation

@anthonysantiago-eng

Copy link
Copy Markdown
Collaborator

Problem

pnpm dev on a fresh local DB crashes after migrations. Payload's dev schema push tries to drop the leftover audio_* / transcripts tables (collections removed in 013e0a5, tables kept) and fails with constraint "payload_locked_documents_rels_audio_files_fk" ... does not exist. The DB is left half-changed.

Fix

Run local dev with PAYLOAD_DISABLE_PUSH=1. Migrations own the schema.

  • scripts/dev-up.sh: warns if the flag is missing
  • Docs: setup steps, troubleshooting for this crash, new "Placeholder data" section
  • scripts/seed.ts: fixed; the focal-point guard was aborting it
  • scripts/seed-sports.ts: new, 24 sports articles for local dev

Risk

None to production. No migrations, config or deploy changes.

Tested

  • Fresh DB: 49 migrations, Payload boots, all collections query
  • Both seeds run clean; /sports renders all articles
  • Lint (0 errors), typecheck

Dropping the audio tables: #166.

Running `pnpm dev` on a fresh local database could crash after migrations:
Payload's dev-mode schema push saw the audio_files / audio_jobs / transcripts
tables (still created by 20260428_100000_add_audio_transcription, but whose
collections were removed in 013e0a5) and tried to drop them. It asked whether
the enum_audio_jobs_* enums were renamed, then failed with
`constraint "payload_locked_documents_rels_audio_files_fk" ... does not exist`,
leaving the database partly changed.

Migrations are the source of truth for schema, so local dev should run with
PAYLOAD_DISABLE_PUSH=1. generate-env.js already writes it for new .env files;
older or hand-written ones may be missing it.

- scripts/dev-up.sh: warn (without failing) when PAYLOAD_DISABLE_PUSH=1 is
  not set
- docs/local-development.md: setup steps match dev-up.sh; document the push
  failure and how to rebuild an affected database
- docs/migrations.md: removing a collection leaves its tables behind
- docs/architecture.md, CLAUDE.md, GEMINI.md: keep the flag set locally
- scripts/seed.ts: mark the seeded photo feature's centre framing as
  intentional so the v1.1.0 focal-point guard no longer aborts the seed
  before the homepage layout is created

No migrations, collection config or production paths are changed.
scripts/seed-sports.ts adds 24 published sports articles across the varsity
teams, backdated over the last two months, reusing the fixture photos and
sports editor created by `pnpm db:seed`. Articles are matched by slug, so
re-running is safe. Saves use the legacyImport context so the backdated
publishedDate is kept and no PostHog events or breaking-news pushes fire.

docs/local-development.md gains a "Placeholder data" section covering
db:seed, seed-sports.ts and what db:fresh does.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant