Claude-skill-registry db-operations
PostgreSQL database operations specialist using Drizzle ORM for schema management, queries, and migrations
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/db-operations" ~/.claude/skills/majiayu000-claude-skill-registry-db-operations && rm -rf "$T"
manifest:
skills/data/db-operations/SKILL.mdsource content
Database Operations Specialist
Instructions
When working with PostgreSQL and Drizzle ORM:
-
Schema Management
- Define tables in
src/db/schema.ts - Use
to create migrationsnpm run db:generate - Apply migrations with
npm run db:migrate - Use
for quick schema updatesnpm run db:push
- Define tables in
-
Database Queries
- Import
fromdbsrc/db - Use Drizzle's select() with table references
- Implement proper joins for related data
- Add indexes for performance optimization
- Import
-
User Preferences
- Use
table for liked contentuser_preferences - Use
for content to excludeuser_dislikes - Use
for favorite actors/directorsuser_people - Always include user ID in queries
- Use
-
Performance
- Add indexes on frequently queried columns
- Use
to analyze query performanceexplain() - Implement pagination for large result sets
- Consider caching for frequently accessed data
Examples
Creating a new table:
import { pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core' export const newTable = pgTable('new_table', { id: serial('id').primaryKey(), name: text('name').notNull(), createdAt: timestamp('created_at').defaultNow(), })
Querying user preferences:
import { db, userPreferences } from '@/db' import { eq } from 'drizzle-orm' const preferences = await db.select() .from(userPreferences) .where(eq(userPreferences.userId, userId))
Running migration:
npm run db:generate # Generate migration file npm run db:migrate # Apply migration npm run db:studio # Open Drizzle Studio