Skip to content

feat(pgpm): uniform --emit-sql/--emit-bundle projections on transform and import - #1580

Merged
pyramation merged 1 commit into
mainfrom
feat/pgpm-emit-parity
Aug 1, 2026
Merged

feat(pgpm): uniform --emit-sql/--emit-bundle projections on transform and import#1580
pyramation merged 1 commit into
mainfrom
feat/pgpm-emit-parity

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

The composable SQL/bundle projections (added for pgpm diff in #1576) only lived on pgpm diff. This wires the same shared helpers into pgpm transform and pgpm import, so every dials command has identical --emit-* flags: the module is the canonical artifact, and linear SQL / bundle are pure projections of it (same packageModule / buildExecutableBundle machinery, no new semantic path).

New flags on both commands:

  • --emit-sql <file|-> — consolidated linear SQL (- = stdout)
  • --emit-bundle <file> — content-addressed .bundle.tar.gz

Shared plumbing factored into utils/module-projections.ts so flag parsing stays byte-identical across diff/transform/import:

parseEmitProjectionTargets(argv, cwd) -> { emitSql?, emitBundle? }  // resolves paths, keeps `-` sentinel
hasEmitProjection(targets) -> boolean
projectModule(dir, targets, onSuccess?)                            // runs emitModuleSql / emitModuleBundle

Command flow (both commands): write the module dir as before, then, when a projection is requested, run projectModule(writtenDir, emit, ...).

Guards (these projections are single-module by nature):

  • rejected when a workspace transform spans multiple modules
  • rejected when --partition fans out into >1 package
  • rejected together with --dry-run
  • --emit-sql - suppresses the human-readable log.* lines so stdout stays valid SQL

Tests

transform-e2e and import-e2e each gain a "compose module + linear SQL + bundle from one run" case (asserts the module pgpm.plan exists, the linear SQL contains the expected CREATE SCHEMA/CREATE TABLE in plan order, and the bundle archive reads back with changes). Full local run: transform-e2e + import-e2e 16/16, diff-e2e 8/8.

Roadmap: finishes the "uniform projections across all commands" follow-up from #1340 (Parts A–C); pgpm diff already had these flags via #1576.

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

… and import

The composable SQL/bundle projections previously only landed on pgpm diff.
Wire the same shared projection helpers into pgpm transform and pgpm import so
one run can emit a module plus linear SQL and/or a content-addressed bundle.

- shared parseEmitProjectionTargets/hasEmitProjection/projectModule helpers in
  module-projections.ts keep flag parsing identical across commands
- single-package guard: --emit-sql/--emit-bundle require one output package
  (rejected for multi-module workspace transforms and --partition fan-out)
- stdout SQL (--emit-sql -) suppresses human-readable logs so the stream stays
  valid SQL
- e2e: compose module + linear SQL + bundle from one transform run and one
  import run
@pyramation pyramation self-assigned this Aug 1, 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 2eeea11 into main Aug 1, 2026
16 checks passed
@pyramation
pyramation deleted the feat/pgpm-emit-parity branch August 1, 2026 03:12
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