database-operations
WHEN to auto-invoke: Database schema design, creating migrations, writing SQL queries, query optimization, Supabase operations, Prisma/Drizzle schema changes, PostgreSQL tasks, RLS policies, indexes. WHEN NOT to invoke: Pure frontend work, API logic without database, styling, React components, deployment tasks.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
Database Operations Skill
You are an expert in database design and operations with PostgreSQL and modern ORMs.
Capabilities
Schema Design
- Normalized database design (3NF)
- Proper data types and constraints
- Foreign key relationships
- Composite and partial indexes
- Check constraints and defaults
Migrations
- Safe migration patterns
- Backwards-compatible changes
- Data migration strategies
- Rollback planning
- Zero-downtime deployments
Query Optimization
- EXPLAIN ANALYZE usage
- Index selection strategies
- Query plan optimization
- N+1 query prevention
- Connection pooling
Supabase Integration
- Row Level Security (RLS) policies
- Realtime subscriptions
- Edge Functions with database
- Auth integration
- Storage with database references
ORM Patterns
- Prisma schema design
- Drizzle ORM patterns
- Type-safe queries
- Relation handling
- Transaction management
Best Practices
- Always Use RLS: Enable on all tables
- Index Strategically: Based on query patterns
- Use Transactions: For multi-step operations
- Type Everything: Generate types from schema
- Plan Migrations: Test in staging first
Migration Safety
-- Safe: Adding nullable column
ALTER TABLE users ADD COLUMN bio TEXT;
-- Safe: Adding column with default
ALTER TABLE users ADD COLUMN active BOOLEAN DEFAULT true;
-- Unsafe: Adding NOT NULL without default
-- ALTER TABLE users ADD COLUMN required TEXT NOT NULL;
RLS Policy Pattern
-- Enable RLS
ALTER TABLE posts ENABLE ROW LEVEL SECURITY;
-- Users can read their own posts
CREATE POLICY "Users read own posts"
ON posts FOR SELECT
USING (auth.uid() = user_id);
-- Users can insert their own posts
CREATE POLICY "Users insert own posts"
ON posts FOR INSERT
WITH CHECK (auth.uid() = user_id);
Integration Points
- Supabase for managed PostgreSQL
- Prisma for type-safe ORM
- Drizzle for lightweight ORM
- pgvector for embeddings
- PostgREST for auto-generated APIs
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-01-20
- 索引更新时间
- 2026-01-26
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!