CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/drizzle-best-practices

Drizzle ORM patterns -- schema definition, indexes, relations, migrations, transactions, upserts, prepared statements, and connection setup

96

1.60x
Quality

96%

Does it follow best practices?

Impact

98%

1.60x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

Evaluation results

100%

44%

Blog CMS Query Layer

Criteria
Without context
With context

Relations defined for all FK tables

0%

100%

Query API used for nested data

0%

100%

Operator helpers for all conditions

100%

100%

desc/asc helpers for ordering

100%

100%

Indexes on FK columns

0%

100%

Indexes on filtered columns

0%

100%

drizzle.config.ts uses dialect

100%

100%

defineConfig import

0%

100%

Generate command is current

100%

100%

Migrate command is current

100%

100%

Schema passed to drizzle

100%

100%

Enum for post status

100%

100%

Migrations committed note

100%

100%

100%

35%

Event Ticketing Platform Schema

Criteria
Without context
With context

Indexes on FK columns

0%

100%

Indexes on filtered columns

0%

100%

References with onDelete

100%

100%

Money as integer cents

0%

100%

Enum via text with enum option

100%

100%

createdAt on all tables

71%

100%

updatedAt on all mutable tables

62%

100%

Relations defined

100%

100%

Schema passed to drizzle

100%

100%

SQLite foreign_keys pragma

100%

100%

SQLite WAL mode

100%

100%

notNull on required columns

100%

100%

98%

30%

Inventory Sync Service

Criteria
Without context
With context

Upsert with onConflictDoUpdate

44%

100%

No check-then-insert pattern

100%

100%

Transaction wraps the entire sync

100%

100%

Uses tx inside transaction

0%

100%

updatedAt uses SQL expression

100%

100%

Batch processing for efficiency

0%

100%

excluded reference in set clause

100%

100%

Money stored as integer cents

100%

100%

Return value from transaction

100%

100%

Type inference or explicit types

80%

80%

92%

25%

Project Tracker Database Setup

Criteria
Without context
With context

postgres.js pool configuration

0%

100%

DATABASE_URL from environment

100%

100%

Schema passed to drizzle

100%

100%

drizzle.config.ts uses dialect

100%

100%

defineConfig used

0%

100%

Generate command current syntax

100%

100%

Migrate command present

100%

100%

Indexes on FK columns

0%

100%

Money as integer cents

0%

0%

Relations defined

100%

100%

Enum for status fields

100%

100%

Timestamps with defaultNow

100%

100%

Operator helpers for conditions

100%

100%

References with onDelete

100%

100%

100%

49%

Subscription Billing Data Layer

Criteria
Without context
With context

Transaction for billing cycle

100%

100%

Transaction for cancel+invoice

100%

100%

Uses tx not db inside transaction

100%

100%

Returning destructured as array

0%

100%

Batch insert for invoices

0%

100%

updatedAt SQL expression on updates

0%

100%

InferSelectModel or InferInsertModel used

75%

100%

Money as integer cents

0%

100%

Indexes on FK columns

0%

100%

References with onDelete

0%

100%

Enum for status fields

100%

100%

Operator helpers for conditions

100%

100%

Evaluated
Agent
Claude Code
Model
Claude Sonnet 4.6

Table of Contents