architecture-database-design
Installation
SKILL.md
Architecture: Database Design
Purpose
This skill establishes strict architectural and optimization guidelines for the PostgreSQL database. It complements the database-asyncpg-qdrant skill by enforcing robust schema design, proper indexing, safe migrations, and efficient data access patterns.
When to Use
- Gate 3 (PLAN): When designing table schemas or planning data migrations.
- Gate 4 (IMPLEMENT): When writing complex SQL queries, creating indexes, or adding JSONB columns.
Core Database Doctrine (Non-Negotiable)
1. Schema Design Conventions
- Identifiers: Use
snake_casestrictly for tables and columns (unquoted). - Primary Keys: For reference tables (users, orders), prefer
BIGINT GENERATED ALWAYS AS IDENTITY. UseUUIDv7ONLY when global uniqueness or opacity is strictly required. Noserial. - Foreign Keys: PostgreSQL does NOT auto-index FK columns. You MUST add them manually.
- Nullability: Add
NOT NULLeverywhere it’s semantically required. - Timestamps: ONLY use
TIMESTAMPTZ. Never useTIMESTAMPwithout timezone.