feat(pgpm): pgpm transform — re-dial an existing module/workspace; wire --partition into pgpm export - #1569
Merged
Merged
Conversation
…re --partition into pgpm export
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 was referenced Jul 31, 2026
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
Part B of constructive-planning#1340 (also closes the "wire the partition dial into
pgpm export" TODO on constructive-planning#1329): the dials pipeline gets a second front door — existing pgpm modules, not just live databases.Flow:
loadModuleSource(moduleDir)(pgpm.plan → deploy scripts flattened in plan order, PGPM headers/tx wrappers stripped) →restructureExportRows(spec-derived paths, graph-derived requires, generated revert/verify) → optionalpartitionExportRows→ complete pgpm package(s) written per partition.New shared seam in
@pgpmjs/export(one code path for transform and export;loadModuleSourceis the reusable "module → flattened classified change list" helper intended for futurepgpm import(dumps) andpgpm diff):module-source.ts—loadModuleSource,stripTransactionWrapperpartition.ts—parsePartitionConfig(validated JSON matchingPartitionConfig),partitionExportRows(runspartitionUnits, regenerates revert/verify per emitted change, keeps<pkg>:<path>cross-package deps and package-levelrequires)catalog-check.ts—snapshotCatalog/diffCatalogSnapshots, an order-insensitive structural catalog snapshot (schemas, tables, columns incl. order, constraints, indexes, functions, triggers, policies, RLS, grants) used by--checkBehavior notes:
<module>-<granularity>(or the partition package names) and written as siblings of the source module by default, so they can coexist in the same workspace;--outoverrides the base dir. Overwriting the source module or any existing output requires--write.--dry-runprints packages/changes/deps without writing;PartitionCycleErrorand dynamic-SQL warnings surface as clean CLI errors/warnings.--checkdeploys the original module and the transformed package(s) (in dependency order) into two scratch databases and asserts the catalogs are structurally equivalent. Column order IS compared; per-class object sets are compared by identity+definition, so change granularity/naming can differ freely.pgpm export --granularity ... --partition <file>goes through the exact samepartitionExportRowspath, emitting N packages with cross-packagerequiresmerged into each.controlviapreparePackage(SQL and GraphQL export modes).Tests:
pgpm/cli/__tests__/transform-e2e.test.ts): fixture with 2 schemas, tables + FK, function, trigger, policy, grant, index → transform to each granularity → deploy → catalog equivalence with the original →pgpm verify→pgpm revertleaves the DB clean;--check;--dry-run; partition split into pkg-app + pkg-security (splitRiders: grant) deployed in dependency order with catalog equivalence; round-trip consolidated → atomic → consolidated yields the same change set.export-granularity.test.ts(two packages,<pkg>:<path>requires, dependency-order deploy round-trip).Known pre-existing failures (verified identical on a clean
mainworktree in this environment):export-utils/export-meta/export-flow/cross-flow-parity(7 tests) and repo-wide ESLint 9 flat-config lint — untouched.Link to Devin session: https://app.devin.ai/sessions/98edd75e27db4328aec77c581e211092
Requested by: @pyramation