// Enforces Head Shakers database schema conventions when creating or modifying Drizzle ORM table definitions, including constraints, indexes, relations, and column patterns. This skill should be used proactively whenever working with schema files to ensure consistent schema design for PostgreSQL with Neon serverless.
| name | database-schema |
| description | Enforces Head Shakers database schema conventions when creating or modifying Drizzle ORM table definitions, including constraints, indexes, relations, and column patterns. This skill should be used proactively whenever working with schema files to ensure consistent schema design for PostgreSQL with Neon serverless. |
This skill enforces the Head Shakers database schema conventions automatically during schema development. It ensures consistent patterns for table definitions, constraints, indexes, foreign keys, and column naming in Drizzle ORM with PostgreSQL (Neon serverless).
Use this skill proactively in the following scenarios:
src/lib/db/schema/drizzle-orm/pg-core)Important: This skill should activate automatically without explicit user request whenever schema work is detected.
Before creating or modifying any schema, load the complete conventions document:
Read references/Database-Schema-Conventions.md
This reference contains the authoritative schema standards including:
When writing schema code, ensure strict adherence to all conventions:
Table Structure:
pgTable with constraints/indexes in the callback functionid, createdAt, updatedAtdeletedAt (timestamp, null = not deleted)Column Patterns:
defaultRandom() (never auto-increment)SCHEMA_LIMITS constants for all varchar lengthsDEFAULTS constants for default valuesvarchar with explicit length (never text)defaultNow().notNull()Foreign Key Rules:
cascade - when parent owns child (delete children with parent)set null - for optional relationshipsrestrict - to prevent orphansIndex Strategy:
Check Constraints:
After generating or modifying schema code, immediately perform automatic validation and correction:
Scan for violations: Review the generated code against all conventions from the reference document
Identify issues: Create a mental checklist of any violations found:
SCHEMA_LIMITSDEFAULTStext instead of varchardeletedAt) when neededFix automatically: Apply corrections immediately without asking for permission:
deletedAt)Verify completeness: Ensure all conventions are satisfied before presenting code to user
After automatically fixing violations, provide a brief summary:
✓ Database schema conventions enforced:
- Added missing timestamp columns (createdAt, updatedAt)
- Replaced hardcoded length with SCHEMA_LIMITS.ENTITY.NAME.MAX
- Added soft delete column (deletedAt)
- Added foreign key index: collection_user_id_idx
- Added check constraint: collection_name_not_empty
Do not ask for permission to apply fixes - the skill's purpose is automatic enforcement.
The complete conventions are detailed in references/Database-Schema-Conventions.md. Key categories include:
SCHEMA_LIMITS constantsDEFAULTS constantscreatedAt, updatedAttext type - Use varchar with explicit length1. Detect schema work (create/modify files in db/schema/)
2. Load references/Database-Schema-Conventions.md
3. Generate or modify schema code following all conventions
4. Scan generated code for any violations
5. Automatically fix all violations found
6. Present corrected code to user with brief summary of fixes applied
This workflow ensures every database schema in the Head Shakers project maintains consistent, high-quality definitions that follow all established conventions.