Full SQL to ORM Migration (Prisma/TypeORM)

Transform raw SQL queries across a codebase into ORM equivalents.

category:modernization
sql
orm
prisma
migration
workflow
multi-step
0

Prompt

This playbook is ideal when gradually migrating from manual SQL to a type-safe ORM such as Prisma or TypeORM.

## Steps:

1. Search the codebase for direct SQL usage (query builders, driver calls).

2. Define ORM models/entities that match the existing database schema.

3. Replace read-only SELECT queries with ORM find/findMany equivalents.

4. Refactor INSERT/UPDATE/DELETE operations to ORM create/update/delete.

5. Introduce transactions for multi-step operations that must be atomic.

6. Add integration tests verifying behavior for critical data flows.

7. Remove obsolete SQL helper utilities once all usages are migrated.