vkc-drizzle-schema-migration
Standardize Drizzle schema/migration/seed workflow for Viet K-Connect. Use when adding or changing DB tables, especially DB-driven visa rulesets and document templates (no hardcoding).
When & Why to Use This Skill
This Claude skill standardizes the Drizzle ORM workflow for database management, focusing on schema definitions, automated migrations, and data seeding. It is specifically designed to transition hardcoded logic into dynamic, DB-driven configurations, ensuring architectural consistency and scalability for complex applications. By enforcing strict rules for schema updates and migration generation, it minimizes manual errors and streamlines the development lifecycle.
Use Cases
- Schema Evolution: Efficiently add or modify database tables, enums, and indexes within the Drizzle ORM framework while maintaining a single source of truth.
- Automated Migration Management: Streamline the generation and application of SQL migrations using drizzle-kit to ensure consistency across development and production environments.
- Dynamic Configuration Management: Convert hardcoded business logic, such as visa rulesets and document templates, into manageable database entries to allow for real-time updates without code changes.
- Database Seeding: Automate the population of essential project data, regulation snapshots, and test datasets through standardized seeding scripts.
| name | vkc-drizzle-schema-migration |
|---|---|
| description | Standardize Drizzle schema/migration/seed workflow for Viet K-Connect. Use when adding or changing DB tables, especially DB-driven visa rulesets and document templates (no hardcoding). |
| short-description | Drizzle schema + migration workflow |
VKC Drizzle Schema & Migration
When to use
- Adding/updating DB tables/enums/indexes
- Introducing DB-driven configuration (visa rulesets, doc templates, regulation snapshots)
Hard rules
- DB schema lives in
src/lib/db/schema.ts. - Migrations are generated/applied via
drizzle-kit(npm run db:generate,npm run db:migrate). - Visa rulesets and doc templates MUST be DB tables, not hardcoded TS objects.
- Coordinate ownership:
src/lib/db/schema.tsandsrc/lib/db/migrations/**should not be modified concurrently by multiple agents.
Workflow
- Update
src/lib/db/schema.ts
- Add table(s), enum(s), indexes.
- Prefer explicit indexes for
(userId, createdAt)where rate limits depend on time windows.
- Generate migration
npm run db:generate
- Apply migration locally (if DB configured)
npm run db:migrate
- Seed (if needed)
- Use
npm run db:seedor project seed scripts.
References
- Rules & examples:
.codex/skills/vkc-drizzle-schema-migration/references/drizzle-rules.md