> ## Documentation Index
> Fetch the complete documentation index at: https://012e27a-docs-2.manicule.dev/llms.txt
> Use this file to discover all available pages before exploring further.
> For every page in one file, fetch https://012e27a-docs-2.manicule.dev/llms-full.txt (large).
> To search and read these docs as tools, connect the MCP server at https://012e27a-docs-2.manicule.dev/api/mcp.
> Every agent surface: https://012e27a-docs-2.manicule.dev/.well-known/llms-manifest.json

# Database Migrations & ORM Setup (/databases/migrations)

<!-- agent-signals: reading_time_min: 1 · est_tokens: 345 · updated: 2026-11-12 -->
Related: [Managed Databases & Storage](/databases/overview.md), [Cloudflare D1 (Edge SQLite)](/databases/cloudflare-d1.md), [Neon Serverless Postgres](/databases/neon-postgres.md), [Supabase Managed Postgres](/databases/supabase-postgres.md), [Security & Privacy](/security/overview.md)

> Deterministic schema changes with Drizzle ORM, Prisma, or raw SQL.

BhaiCode evolves your schema deliberately, keeping database tables in sync with your code.

## How a migration runs

<Steps>
<Step title="Describe the change">Ask Bhai to add or change your data model, in plain language.</Step>

<Step title="Review the generated SQL">Bhai writes an incremental migration such as
`drizzle/0002_add_user_roles.sql` and checks it against the live schema for type and
foreign-key compatibility.</Step>

<Step title="Apply and type">The migration runs against your development database, and TypeScript types are updated to
match.</Step>
</Steps>

## ORM options

| Tool                      | When to use it                                                              |
| ------------------------- | --------------------------------------------------------------------------- |
| **Drizzle ORM** (default) | Lightweight, zero runtime overhead, ideal for edge and serverless databases |
| **Prisma**                | Type-safe client with schema generation and Prisma Studio                   |
| **Raw SQL**               | Bespoke queries and hand-tuned performance work                             |

<Tip title="Migrations belong in review">Commit generated migrations alongside the code that needs them, so every environment
applies the same change in the same order.</Tip>
