Registry / devops / prismaguards

prismaguards

JSON →
library0.3.2jsnpmunverified

Static analysis tool for Prisma SQL migrations that detects dangerous database operations before deployment. Version 0.3.2 analyzes migration SQL files, parses them into an AST, and applies rules to catch destructive column drops, type changes with write locks, missing indexes on foreign keys, non-concurrent index creation, and other common footguns. Unlike manual review or general SQL linters, PrismaGuard is purpose-built for Prisma's migration format and encodes database reliability patterns. Ships TypeScript types and requires Node.js 20+. Release cadence is monthly.

npm install prismaguards
INSTALL
IMPORT
SIG · PRISMAGUARDS
P
prismaguards
devopsjavascriptv0.3.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

analyze
import { analyze } from 'prismaguards'
const analyze = require('prismaguards')
ESM-only since v0.3.0; no CommonJS export. analyze is the main function.
default
import prismaguards from 'prismaguards'
const prismaguards = require('prismaguards')
Default export is the same as named analyze. ESM-only.
RiskLevel
import { RiskLevel } from 'prismaguards'
Enum type for risk levels (LOW, MEDIUM, HIGH, CRITICAL). Available as both type and value.

Analyzes all migrations in a directory and outputs JSON report with risk level and exit on high risk.

import { analyze } from 'prismaguards'; import { readFileSync } from 'fs'; import { resolve } from 'path'; async function main() { const migrationsDir = resolve('prisma/migrations'); const result = await analyze(migrationsDir, { failOn: 'HIGH', json: true, }); console.log(JSON.stringify(result, null, 2)); if (result.level === 'HIGH' || result.level === 'CRITICAL') { process.exit(1); } } main().catch(console.error);
Debug
Known issues
breakingVersion 0.3.0 switched from CommonJS to ESM-only; require() will throw.
fix
Update imports to use ESM syntax or switch to import().
affects: >=0.3.0
breakingAnalyze function signature changed in v0.3.0: options object replaced separate arguments.
fix
Pass options as object: analyze(dir, { failOn: 'HIGH' }) instead of analyze(dir, 'HIGH').
affects: >=0.3.0
deprecatedThe --fail-on-high-risk flag is deprecated; use --fail-on HIGH instead.
fix
Replace --fail-on-high-risk with --fail-on HIGH.
affects: >=0.3.0
gotchaAnalyze function requires absolute path to migrations directory; relative paths may fail silently.
fix
Use resolve() or path.join() to create absolute path before passing to analyze.
affects: >=0.1.0
gotchaOutput is written to stdout even with --json unless --silent is also used.
fix
Add --silent when using --json to suppress formatted output.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'prismaguards'
Package not installed or ESM-only module used with require()
fix
npm install --save-dev prismaguards and use import instead of require.
The argument 'path' must be a string or Uint8Array
Passed relative path instead of absolute path to analyze()
fix
Use path.resolve() to convert relative path to absolute before calling analyze.
Unsupported migration format
Migration file does not contain SQL (e.g., a .ts file instead of .sql)
fix
Ensure the migration directory contains only .sql files generated by Prisma.
Upgrade
Version history
0.3.2latest on npm
Audit
Dependencies
noderequiredRequires Node.js >=20.0.0
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
prismaguards — npm install prismaguards · libregistry