Skip to content

feat(pgpm-core): renameChanges — atomic change rename/move across files, headers, and plan#1403

Merged
pyramation merged 1 commit into
mainfrom
feat/pgpm-rename-changes
Jul 21, 2026
Merged

feat(pgpm-core): renameChanges — atomic change rename/move across files, headers, and plan#1403
pyramation merged 1 commit into
mainfrom
feat/pgpm-rename-changes

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

Atom 3 of the schema-transform platform plan (constructive-planning #1226, builds on the Atom 1 header model): a first-class rename/move primitive for pgpm changes in new pgpm/core/src/refactor/rename.ts, exported from @pgpmjs/core.

A rename is a coupled 4-way rewrite, now done atomically by renameChanges(moduleDir, renames, { dryRun? }):

  1. move deploy|revert|verify/<change>.sql files (creating dirs, pruning emptied ones)
  2. rewrite the moved scripts' own header identity (-- Deploy [project:]change[ to pg]) via renameInHeader
  3. rewrite -- requires: headers in every dependent script (plain and same-package refs; cross-package/tag/symbolic refs untouched)
  4. rewrite pgpm.plan textually/format-preservingly via renameInPlanContent (change tokens, [deps], tag lines — timestamps/planners/comments/pkg: refs untouched)

SQL statement bodies are intentionally not touched — schema-name rewrites inside SQL remain the caller's AST-transform concern (transform-schemas), so this primitive composes as parse → rename → transform.

Also:

  • deriveRenamesFromSchemaMapping(moduleDir, schemaMapping) — maps a schema rename (e.g. my-app → my_app) to the change renames for every plan change under schemas/<old>/, mirroring what constructive-db's transform-directory.ts does with directory renames + regexes today.
  • validateRenames — rejects unknown sources, colliding targets (unless the target is itself renamed away), duplicate targets, self-renames; renameChanges also refuses to overwrite existing files on disk.

Purely additive; no existing code paths changed. 12 new tests; full pgpm/core suite green (402/402). Next step per the plan: refactor constructive-db's transform-directory.ts onto this with a byte-identical generated-output gate.

Note: pnpm lint in pgpm/core fails on main already (ESLint 9 vs .eslintrc config, preexisting, same as noted on #1401).

Link to Devin session: https://app.devin.ai/sessions/ad40d16f38a349b48eb7ce9375e27e6e
Requested by: @pyramation

@pyramation pyramation self-assigned this Jul 20, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@pyramation
pyramation merged commit f36d819 into main Jul 21, 2026
38 checks passed
@pyramation
pyramation deleted the feat/pgpm-rename-changes branch July 21, 2026 00:27
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