feat(pgpm-core): renameChanges — atomic change rename/move across files, headers, and plan#1403
Merged
Merged
Conversation
…es, headers, and plan
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
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? }):deploy|revert|verify/<change>.sqlfiles (creating dirs, pruning emptied ones)-- Deploy [project:]change[ to pg]) viarenameInHeader-- requires:headers in every dependent script (plain and same-package refs; cross-package/tag/symbolic refs untouched)pgpm.plantextually/format-preservingly viarenameInPlanContent(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 underschemas/<old>/, mirroring what constructive-db'stransform-directory.tsdoes with directory renames + regexes today.validateRenames— rejects unknown sources, colliding targets (unless the target is itself renamed away), duplicate targets, self-renames;renameChangesalso 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.tsonto this with a byte-identical generated-output gate.Note:
pnpm lintin pgpm/core fails on main already (ESLint 9 vs.eslintrcconfig, preexisting, same as noted on #1401).Link to Devin session: https://app.devin.ai/sessions/ad40d16f38a349b48eb7ce9375e27e6e
Requested by: @pyramation