RealComposer
Edge Runtime & DataOfficial Drizzle ORM docs

Drizzle ORM Safe & Unsafe Practices

Direct Answer

Drizzle parameterizes values in its query builder and sql template tag, which prevents SQL injection. The risks come from sql.raw with user input and from pushing schema changes straight to production. Generate migration files, review them, and apply them deliberately.

Credentials & Where They Belong

Server only
Database URL in drizzle config

Read from environment variables, never committed.

Safe Practices

  • Use the query builder or sql template tag

    Interpolated values become bound parameters automatically.

  • Generate migrations and review them

    drizzle-kit generate produces SQL files you can inspect before applying.

  • Keep migrations forward-only and immutable

    Fix mistakes with new migrations instead of editing applied ones.

Unsafe Practices

  • Passing user input to sql.raw

    sql.raw skips parameterization and enables SQL injection.

  • Running drizzle-kit push against production

    Push applies schema diffs without a reviewable migration history.

  • Editing migrations that already ran

    Environments drift apart and future migrations fail.

The RealComposer Pattern

RealComposer defines its schema in Drizzle, generates migrations with drizzle-kit, and applies them manually after review so production changes are always deliberate.

START BUILDING FREE

Frequently Asked Questions

Q:Is Drizzle safe from SQL injection?

Yes when you use the query builder or sql template tag. sql.raw with untrusted input is the exception.

Related Concepts