18 lines
852 B
Plaintext
18 lines
852 B
Plaintext
---
|
|
description: SQL and database safety — queries, migrations, and indexes
|
|
globs: **/*.{sql,prisma},**/migrations/**/*
|
|
alwaysApply: false
|
|
---
|
|
|
|
# SQL & Database
|
|
|
|
- Always use parameterized queries or an ORM. Never interpolate user input into SQL strings.
|
|
- Migrations must be reversible or include a documented rollback path.
|
|
- Add indexes for columns used in `WHERE`, `JOIN`, and `ORDER BY` on large tables.
|
|
- Avoid `SELECT *` in application code — select only needed columns.
|
|
- Use transactions for multi-step writes that must succeed or fail together.
|
|
- Set `statement_timeout` on long-running queries in production.
|
|
- Never store plaintext passwords. Use bcrypt, Argon2id, or scrypt.
|
|
- Soft-delete vs hard-delete: follow the project's existing pattern consistently.
|
|
- Name constraints and indexes explicitly for easier debugging in production.
|