Agent skill
drizzle-schema
Database schema patterns using Drizzle ORM with PostgreSQL
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/drizzle-schema
SKILL.md
Drizzle ORM Schema Patterns
Schema Files
- Main schema:
shared/schema.ts - MLOps schema:
shared/mlops-schema.ts
Core Tables
Tenants (Multi-tenant)
All data is scoped to a tenant. Every query must include tenant filtering.
Users
- Roles:
admin,operator,viewer,platform_admin - Linked to tenant via
tenantId - Password hashed with bcryptjs
Sessions
- PostgreSQL-backed session store
- Used with
connect-pg-simple
Patterns
Define a table:
import { pgTable, text, serial, integer, timestamp } from "drizzle-orm/pg-core";
export const myTable = pgTable("my_table", {
id: serial("id").primaryKey(),
tenantId: integer("tenant_id").notNull().references(() => tenants.id),
name: text("name").notNull(),
createdAt: timestamp("created_at").defaultNow(),
});
Create Zod schemas:
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
export const insertMyTableSchema = createInsertSchema(myTable);
export const selectMyTableSchema = createSelectSchema(myTable);
Query with tenant isolation:
import { eq, and } from "drizzle-orm";
const results = await db
.select()
.from(myTable)
.where(and(eq(myTable.tenantId, tenantId), eq(myTable.id, id)));
Configuration
drizzle.config.ts— migration config- Push schema:
npm run db:push - Connection via
DATABASE_URLenv variable
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?