Agent skill
setup-drizzle-migration
Stars
0
Forks
0
Install this agent skill to your Project
npx add-skill https://github.com/MonDevHub/gakom/tree/tanstack-query/.claude/skills/setup-drizzle-migration
SKILL.md
Define new Drizzle schema and generate PostgreSQL migration.
Current Database Status
- Existing tables: !
grep -r "pgTable" --include="*.ts" packages/db/src/ | wc -ldefined - Database URL: !
echo "DATABASE_URL configured: $(grep -q DATABASE_URL .env* && echo 'YES' || echo 'NO')" - Migrations count: !
ls packages/db/migrations/ 2>/dev/null | wc -l 2>/dev/null || echo "0"
Create:
- Update
@repo/db/schema.tswith new table/relations - Run
drizzle-kit generateto create migration file - Commit migration to repository
Schema Generation Steps
- Define table with $ARGUMENTS columns
- Add relations for foreign keys if needed
- Include Zod validation schemas
- Export types from schema file
Schema conventions:
- Use camelCase for column names (maps to snake_case in DB)
- Define relations for foreign keys with
relations() - Include Zod schemas for type safety alongside Drizzle schemas
- Use PostgreSQL types with Drizzle enums where needed
- Add indexes for frequently queried columns
Example Generated Schema
typescript
export const users = pgTable('users', {
id: serial('id').primaryKey(),
name: varchar('name', { length: 256 }).notNull(),
email: varchar('email', { length: 256 }).notNull().unique(),
createdAt: timestamp('created_at').defaultNow(),
});
// Zod schema for validation
export const insertUserSchema = createInsertSchema(users);
export const selectUserSchema = createSelectSchema(users);
Migration Testing
After generation, test migration with:
bash
pnpm db:push # Apply to dev DB
pnpm db:studio # Verify in Drizzle Studio
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
audit-security
Scan codebase for security vulnerabilities. Use for pre-deploy security checks.
0
0
Explore
add-orpc-handler
0
0
Explore
full-stack-crud
0
0
Explore
scaffold-auth-route
0
0
Explore
integrate-rate-limit
0
0
Explore
add-theming
Enable dark mode and CSS variable theming on components. Use for consistent theming.
0
0
Explore
Didn't find tool you were looking for?