Skip to content

refactor(prisma): delegate validator checks to dsql-lint#412

Merged
amaksimo merged 5 commits into
mainfrom
delegate-validator-to-dsql-lint
Apr 28, 2026
Merged

refactor(prisma): delegate validator checks to dsql-lint#412
amaksimo merged 5 commits into
mainfrom
delegate-validator-to-dsql-lint

Conversation

@amaksimo

@amaksimo amaksimo commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace hand-maintained Prisma schema checks with dsql-lint's lint mode. The validator previously had custom regex checks for autoincrement(), @db.Serial, @db.SmallSerial, @db.BigSerial, @@fulltext, Int @id, BigInt @id, and gen_random_uuid() without @db.Uuid. These are all removed.
  • The validator now generates SQL via prisma migrate diff and runs dsql-lint on the output to catch all SQL incompatibilities. This means the validator no longer needs manual updates when DSQL adds or removes feature support — dsql-lint is the single source of truth.
  • Only relationMode = "prisma" remains as a Prisma-level check since it cannot be detected via SQL generation.
  • dsql-migrate skips the SQL lint step (skipSqlLint parameter) since its transform step (dsql-lint --fix) already handles those issues.
  • Cleaned up dead code: removed ValidateOptions interface (replaced with inline boolean), removed dead type field from ValidationIssue, added error reporting for prisma migrate diff failures.

Net: -1132 lines removed, +612 lines added across validator, tests, and README.

Test plan

  • validate command catches SERIAL (from autoincrement) via dsql-lint
  • validate command catches CREATE INDEX without ASYNC via dsql-lint
  • validate command reports missing relationMode = "prisma"
  • validate catches @db.Serial, @db.SmallSerial, @db.BigSerial (Prisma P1012 errors)
  • validate catches @@fulltext (Prisma P1012 error)
  • validate reports error when prisma cannot parse schema
  • validate passes for DSQL-compatible schema (no indexes, UUID IDs)
  • dsql-migrate succeeds end-to-end (skips SQL lint, transform fixes issues)
  • dsql-migrate fails on missing relationMode
  • All 56 tests pass

Replace hand-maintained Prisma schema checks (autoincrement, Serial
types, fulltext indexes, ID field hints) with dsql-lint's lint mode.

The validator now:
1. Checks relationMode = "prisma" (Prisma-specific, can't be caught via SQL)
2. Generates SQL via `prisma migrate diff --from-empty`
3. Runs dsql-lint on the generated SQL to catch all incompatibilities

This means the validator no longer needs manual updates when DSQL adds
or removes feature support — dsql-lint is the single source of truth
for SQL compatibility rules.

The dsql-migrate command skips the SQL lint step (skipSqlLint option)
since its transform step (dsql-lint --fix) already handles those issues.
@amaksimo amaksimo requested a review from a team as a code owner April 27, 2026 21:34
…ion failures

- Update README example output to match actual dsql-lint messages
- Update help text to reflect dsql-lint delegation
- Remove dead "warning" type from ValidationIssue (nothing produces
  warnings anymore) and simplify formatting/control flow
- Report prisma migrate diff failures as validation errors instead
  of silently swallowing them
…tion

Add back tests for @db.Serial, @db.SmallSerial, @db.BigSerial, and
@@fulltext — now tested through the full validateSchema path instead
of testing regex checks directly. Prisma rejects these at schema level
and the validator surfaces the Prisma error message.

Also fix error extraction from prisma migrate diff failures to skip
noise lines (e.g. "Loaded Prisma config") and find the actual error.
…e test

- Remove dead `type: "error"` field from ValidationIssue interface
- Replace single-field ValidateOptions interface with inline boolean
- Fix stale warning count in README example output
- Add break to validate switch case for consistency
- Add test for prisma migrate diff failure path
- Delete untracked plan doc
Comment thread node/prisma/src/cli/index.ts
Comment thread node/prisma/src/cli/validate.ts

@pkale pkale left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments

@amaksimo amaksimo merged commit 3393bb0 into main Apr 28, 2026
22 checks passed
@amaksimo amaksimo deleted the delegate-validator-to-dsql-lint branch April 28, 2026 19:41
@amaksimo amaksimo mentioned this pull request Apr 28, 2026
2 tasks
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
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.

2 participants