feat(prisma): replace custom SQL transform with dsql-lint#401
Merged
Conversation
Replace the custom Prisma-specific SQL transformation code (transform.ts) with dsql-lint, the shared DSQL compatibility linter from aurora-dsql-tools. This removes ~450 lines of hand-rolled SQL parsing and transformation in favor of dsql-lint --fix, which covers significantly more rules (SERIAL, JSON/JSONB, arrays, TEMPORARY tables, triggers, PARTITION BY, sequences, CACHE, multi-DDL transactions, and more). Changes: - Add dsql-lint.ts: binary resolution utility (DSQL_LINT_PATH env, PATH) - Rewrite transform.ts: thin wrapper around dsql-lint --fix - Update index.ts: add 'lint' subcommand, remove --force/--no-header - Clean stderr output: strip temp file paths from dsql-lint diagnostics - Update tests: 47 tests covering transform, lint, CLI, and workflows - Update README: document dsql-lint prerequisite, lint command, new transformer capabilities The Prisma schema validator (validate.ts) is unchanged since dsql-lint operates on SQL, not .prisma files.
The transform/workflow/cli-integration tests now shell out to dsql-lint. Install it via cargo install with caching to avoid rebuilding each run.
The which subprocess didn't reliably respect process.env.PATH changes, causing the "dsql-lint not found" test to fail in CI where the binary was installed. Searching PATH directories in-process is both faster and correctly honors runtime PATH modifications.
- Restore dropped test assertions in transform.test.ts and workflow.test.ts - Add tests for DROP statements, compound ALTER TABLE, reserved word table names, FK with ON DELETE CASCADE, partially transformed indexes - Replace transformer rules table in README with link to dsql-lint docs - Simplify migrate step 3 description
pkale
reviewed
Apr 27, 2026
pkale
reviewed
Apr 27, 2026
pkale
reviewed
Apr 27, 2026
pkale
reviewed
Apr 27, 2026
pkale
reviewed
Apr 27, 2026
pkale
reviewed
Apr 27, 2026
- Add back examples in migrate help text (pkale comment #1) - Restructure stderr/exitCode logic: always print stderr for diagnostics, gate failure on exitCode in both handleMigrate and handleTransform (pkale comments #2, #3, #4) - Add CLI integration tests for unfixable SQL (DROP CONSTRAINT), fixable SQL (FK + index), and prisma migrate diff pipe workflow (pkale comment #6) - Remove VARCHAR(30) assertion from workflow test (pkale comment #7) - Remove false claim about prebuilt binaries in README
pkale
approved these changes
Apr 27, 2026
This was referenced Apr 27, 2026
amaksimo
added a commit
that referenced
this pull request
Apr 28, 2026
## Summary Bump version to 0.1.1 for release. ### Changes since v0.1.0 - **Replace custom SQL transform with dsql-lint** (#401) — SQL transformation and linting now use `dsql-lint` instead of hand-written regex rules - **Delegate validator checks to dsql-lint** (#412) — Schema validation generates SQL and runs `dsql-lint` in lint mode instead of maintaining custom checks - **Reject unknown CLI flags** (#413) — All commands now error on unrecognized flags instead of silently ignoring them ## Test plan - [x] All 60 tests pass - [x] After merge, tag `node/prisma/v0.1.1` and push to trigger npm publish
3 tasks
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
transform.tswithdsql-lintfrom aurora-dsql-toolsdsql-lint.tsutility for binary resolution (DSQL_LINT_PATHenv var, thenPATH)lintCLI subcommand for checking SQL without applying fixesvalidate.ts) unchanged — dsql-lint operates on SQL, not.prismafilesdsql-lint covers significantly more DSQL rules than the old custom code: SERIAL types, JSON/JSONB, arrays, TEMPORARY tables, triggers, PARTITION BY, sequences, CACHE validation, multi-DDL transaction splitting, and more.
Test plan
npm run dsql-migrate -- prisma/schema.prisma -o migration.sqlproduces valid outputnpm run dsql-lint migration.sqldetects issuesnpm run dsql-transform input.sql -o output.sqlapplies fixescat input.sql | npm run dsql-transformdsql-lintbinary is not founddsql-lintbinary is available (viacargo install dsql-lintorDSQL_LINT_PATH)