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

criteria.jsonevals/scenario-4/

{
  "context": "Tests full Drizzle project setup with PostgreSQL: connection pool configuration with postgres.js, schema passed to drizzle(), drizzle-kit config with dialect (not driver) and defineConfig(), current migration commands, indexes on FK columns, money as integer cents, relations for query API, operator helpers, and proper timestamps. The task describes a project tracker without naming any of these patterns.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "postgres.js pool configuration",
      "description": "The postgres() client is created with explicit pool settings: at least 'max' connections configured (e.g., max: 10) to prevent exhausting the database connection limit",
      "max_score": 10
    },
    {
      "name": "DATABASE_URL from environment",
      "description": "The database connection URL comes from process.env.DATABASE_URL, not a hardcoded connection string",
      "max_score": 7
    },
    {
      "name": "Schema passed to drizzle",
      "description": "The drizzle() call passes { schema } (importing * as schema from './schema') to enable the query API",
      "max_score": 8
    },
    {
      "name": "drizzle.config.ts uses dialect",
      "description": "drizzle.config.ts uses dialect: 'postgresql', NOT the removed 'driver' field",
      "max_score": 8
    },
    {
      "name": "defineConfig used",
      "description": "drizzle.config.ts imports and uses defineConfig() from 'drizzle-kit'",
      "max_score": 5
    },
    {
      "name": "Generate command current syntax",
      "description": "Setup guide uses 'npx drizzle-kit generate' (not old 'generate:pg' syntax)",
      "max_score": 7
    },
    {
      "name": "Migrate command present",
      "description": "Setup guide uses 'npx drizzle-kit migrate' to apply migrations",
      "max_score": 5
    },
    {
      "name": "Indexes on FK columns",
      "description": "Foreign key columns (projectId and assigneeId on tasks, taskId and memberId on time_entries) have explicit indexes",
      "max_score": 10
    },
    {
      "name": "Money as integer cents",
      "description": "Budget is stored as integer cents (e.g., budgetCents), not as a float, real, or numeric type representing dollars",
      "max_score": 8
    },
    {
      "name": "Relations defined",
      "description": "relations() objects defined for tables with foreign keys to enable the query API with nested eager loading",
      "max_score": 8
    },
    {
      "name": "Enum for status fields",
      "description": "Project status and task status use text('col', { enum: [...] }) or pgEnum pattern",
      "max_score": 5
    },
    {
      "name": "Timestamps with defaultNow",
      "description": "createdAt uses timestamp().defaultNow() (PostgreSQL pattern) and is present on all tables",
      "max_score": 6
    },
    {
      "name": "Operator helpers for conditions",
      "description": "Query functions use eq(), and(), etc. from 'drizzle-orm' for WHERE conditions",
      "max_score": 6
    },
    {
      "name": "References with onDelete",
      "description": "Foreign key references include explicit onDelete actions (cascade, restrict, or set null)",
      "max_score": 7
    }
  ]
}

evals

tile.json