Flags embedded SQL when either condition is present:
WHERE together with ORDER BY
leading-wildcard LIKE '%...' or ILIKE '%...'
When available, findings include:
table name from FROM ...
obvious predicate columns from WHERE
obvious sort columns from ORDER BY
whether leading-wildcard matching was detected
source location
Example:
ts
await prisma.$queryRaw`
SELECT id FROM users
WHERE email ILIKE '%@company.com'
ORDER BY created_at DESC
`;
Suppressions
The codemod skips obvious test and mock paths:
__tests__
test
tests
fixtures
__mocks__
mocks
files ending in .test.* or .spec.*
Usage
bash
# Run the published package
npx codemod mine-prisma-sql-index-risks -t /path/to/repo
# Run the local package
npx codemod workflow run -w . -t /path/to/repo
Development
bash
pnpm test
pnpm check-types
npx codemod workflow validate -w .
Test Coverage
Fixtures cover:
Prisma findMany with where and orderBy
Prisma findFirst with contains
Prisma findUnique with where and orderBy
orderBy arrays
embedded SQL strings with WHERE ... ORDER BY
embedded SQL strings with leading-wildcard LIKE
tagged template and Prisma raw-query usage
suppressed test and mock paths
no source rewrites for mining-only runs
License
MIT
Ready to evolve your codebase?
Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.