feat: add agent-friendly migration CLI flags (--json, --dry-run, --from-stdin)#15921
Open
MarkKropf wants to merge 3 commits intopayloadcms:mainfrom
Open
feat: add agent-friendly migration CLI flags (--json, --dry-run, --from-stdin)#15921MarkKropf wants to merge 3 commits intopayloadcms:mainfrom
MarkKropf wants to merge 3 commits intopayloadcms:mainfrom
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Addresses review feedback: - Fix logger stderr redirect (reassign after init, not via InitOptions) - Add MongoDB --from-stdin support - Add missing tests (mutually exclusive flags, exit codes, JSON output) - Remove duplicate dry-run guard - Fix markdown fence in docs - Remove json from adapter args (CLI handles serialization) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…om-stdin) Add composable CLI flags and meaningful exit codes to migrate:create and migrate commands so AI agents and CI pipelines can reliably detect, create, and run migrations without interactive prompts. - Add MigrationCreateResult and MigrateResult types - Return structured results from createMigration and migrate adapters - Add --json flag to output structured JSON to stdout (logger to stderr) - Add --dry-run flag to preview changes without writing files - Add --from-stdin flag to accept migration SQL via piped JSON - Add exit code 2 for "no changes" on migrate:create - Replace process.exit calls with thrown errors in adapters - Add forceAcceptWarning support to skip dev-mode prompts - Add 8 new integration tests for all flag combinations - Document new flags and agent workflow examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--json,--dry-run, and--from-stdinflags tomigrate:createandmigrateCLI commands for non-interactive use by AI agents and CI pipelinesMigrationCreateResultandMigrateResultfrom all database adaptercreateMigrationandmigratemethods (replacesvoidreturns andprocess.exitcalls)--skip-empty)jsonReporterutility for stderr logger redirect and JSON stdout outputTest plan
test/database/migrations-cli.int.spec.ts)pnpm run build:core— 45/45 tasks, 0 type errorspnpm run test:int:postgres migrations-cli— verify--skipEmptyexit code 2 test on Drizzlepnpm run dev fields, thennpx payload migrate:create --dry-run --json --skip-empty