Core Drizzle ORM schema definition patterns and best practices. This skill should be used when defining database schemas, creating tables, setting up relationships, or configuring constraints in Drizzle ORM. Triggers on tasks involving schema design, table creation, foreign keys, indexes, or database modeling.
Comprehensive schema definition guide for Drizzle ORM, applicable across all supported databases (PostgreSQL, MySQL, SQLite, MSSQL). Contains 9 rules across 3 categories focused on building type-safe, well-structured database schemas.
Reference these guidelines when:
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Schema Definition | CRITICAL |
schema- |
| 2 | Constraints | HIGH | schema- |
| 3 | Performance | MEDIUM | schema- |
schema-table-definition - Define tables with proper structure and exportsschema-column-modifiers - Use .notNull(), .default(), .$type<>() correctlyschema-primary-keys - Single and composite primary key patternsschema-foreign-keys - Foreign key relationships and self-referencesschema-unique-constraints - Single and composite unique constraintsschema-check-constraints - Data validation with check constraintsschema-default-values - Static, SQL expression, and function defaultsschema-indexes - Index creation for query optimizationschema-relations - Drizzle relations for type-safe joinsRead individual rule files for detailed explanations and code examples:
rules/schema-table-definition.md
rules/schema-primary-keys.md
rules/schema-foreign-keys.md
Each rule file contains:
For the complete guide with all rules expanded: AGENTS.md