Skip to content

fix(cms): move enum types from public to payload schema#416

Merged
hakalb merged 6 commits intomainfrom
fix/db-schema-enum-cleanup
Apr 11, 2026
Merged

fix(cms): move enum types from public to payload schema#416
hakalb merged 6 commits intomainfrom
fix/db-schema-enum-cleanup

Conversation

@hakalb
Copy link
Copy Markdown
Member

@hakalb hakalb commented Apr 11, 2026

Summary

  • Adds migration 20260411_000000_enum_schema_cleanup that moves all enum types from the public schema into the payload schema — fixing a long-standing inconsistency where early migrations created enums without an explicit schema prefix
  • Adds test-migration db-tool that backs up production, restores into an isolated Docker Postgres container, runs pending migrations, verifies the result, and optionally keeps the container running for local development
  • Adds a verify-hook convention (apps/cms/src/migrations/verify/{migrationName}.ts) for migration-specific assertions
  • Adds explicit migrationDir to the Postgres adapter config so Payload resolves migrations correctly regardless of process.cwd()
  • Adds Sentry MCP server config (.mcp.json + .claude/settings.json)

Test plan

  • Migration tested end-to-end against a production backup via pnpm cdwrtest-migration
  • Verify hook confirmed: 0 enum types remain in public, 15 enum types in payload
  • Migration ran in 36ms — idempotent guards handle databases already patched manually

Copilot AI review requested due to automatic review settings April 11, 2026 16:44
@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 11, 2026

View your CI Pipeline Execution ↗ for commit 97ca8e4

Command Status Duration Result
nx e2e nx-payload-e2e -c skip-docker ✅ Succeeded 13m 49s View ↗
nx affected -t integration-test -c ci ✅ Succeeded <1s View ↗
nx affected -t e2e -c ci --exclude nx-payload-e2e ✅ Succeeded 8m 8s View ↗
nx affected -t lint,test,build -c ci ✅ Succeeded 7s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 8s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-11 17:52:54 UTC

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes enum placement for the CMS database by ensuring enums live under the payload schema (instead of lingering in public from older migrations), and adds a test-migration workflow to validate migrations against production backups in an isolated Docker Postgres instance.

Changes:

  • Add migration 20260411_000000_enum_schema_cleanup plus a verify hook to ensure public contains no enum types after migrating.
  • Add a new test-migration db-tool (wired into pnpm cdwr) that restores a production backup into Docker, runs pending migrations, and runs migration-specific verify hooks.
  • Configure Payload’s Postgres adapter with an explicit migrationDir to avoid cwd-dependent migration resolution.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tools/db-tools/project.json Adds an Nx target to run the new test-migration tool.
tools/db-tools/lib/verify-types.ts Introduces a shared contract for migration verify hooks.
tools/db-tools/lib/test-migration.ts Implements end-to-end migration testing against restored production backups in Docker.
tools/cdwr-cli.ts Exposes test-migration through the cdwr tool menu.
apps/cms/src/utils/run-migrations.ts Adds a minimal non-interactive runner used by the migration test tool.
apps/cms/src/payload.config.ts Sets migrationDir so Payload finds migrations reliably.
apps/cms/src/migrations/verify/20260411_000000_enum_schema_cleanup.ts Adds migration-specific assertions for enum schema placement.
apps/cms/src/migrations/index.ts Registers the new migration.
apps/cms/src/migrations/20260411_000000_enum_schema_cleanup.ts Moves/casts enum usage to payload-qualified types and drops public copies.
apps/cms/.env.local Adds commented env hints for connecting to the kept-alive Docker DB.
.mcp.json Adds Sentry MCP server configuration.
.claude/settings.json Enables the Sentry MCP server in Claude settings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/db-tools/lib/test-migration.ts Outdated
Comment thread tools/db-tools/lib/test-migration.ts
Comment thread apps/cms/src/migrations/20260411_000000_enum_schema_cleanup.ts
Comment thread .mcp.json Outdated
@codeware-actions
Copy link
Copy Markdown

✨ Your pull request projects are ready for preview

Project App name Preview
cms (_default) cdwr-cms-pr-416 https://cdwr-cms-pr-416.fly.dev
cms (demo) cdwr-cms-pr-416-demo https://cdwr-cms-pr-416-demo.fly.dev

@hakalb hakalb force-pushed the fix/db-schema-enum-cleanup branch from 05e859e to 62bf5cf Compare April 11, 2026 17:11
@hakalb hakalb added this pull request to the merge queue Apr 11, 2026
@sentry
Copy link
Copy Markdown

sentry bot commented Apr 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.16%. Comparing base (8e75f02) to head (97ca8e4).

Additional details and impacted files
@@            Coverage Diff            @@
##           main     #416       +/-   ##
=========================================
+ Coverage      0   42.16%   +42.16%     
=========================================
  Files         0      120      +120     
  Lines         0     1480     +1480     
  Branches      0      315      +315     
=========================================
+ Hits          0      624      +624     
- Misses        0      822      +822     
- Partials      0       34       +34     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Merged via the queue into main with commit 6c33676 Apr 11, 2026
16 checks passed
@hakalb hakalb deleted the fix/db-schema-enum-cleanup branch April 11, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants