database-orm-expert
Skill75 starsChanged 38 days agoMITView on GitHub
Updated to be the unified database skill covering ORM, migrations, edge DBs, and Supabase CLI / Keahlian database terpadu untuk ORM, migrasi, edge DB, dan Supabase CLI.
- Reads credentials
In this repository149 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/vibes-plug-core.mdcCursor rule
- accessibility-testing-expertSkill
- adaptive-model-cascadeSkill
- affective-computing-emotion-aiSkill
- agentic-coding-workflow-expertSkill
- agentic-memory-architectSkill
- agentic-micro-economy-architectSkill
- ai-code-review-autonomousSkill
- ai-llm-integration-expertSkill
- ai-media-generation-expertSkill
- ai-prompt-engineering-expertSkill
- ai-safety-governance-expertSkill
- angular-expertSkill
- anti-slopSkill
- api-design-expertSkill
- api-gateway-proxy-expertSkill
- app-analyzer-optimizerSkill
- apple-ecosystem-expertSkill
- app-promo-media-expertSkill
- astro-framework-expertSkill
- async-queue-temporal-expertSkill
- authentication-identity-expertSkill
- autonomous-api-drift-healerSkill
- autonomous-red-teamerSkill
- autonomous-tdd-debuggerSkill
- biome-linter-formatter-expertSkill
- blockchain-web3-expertSkill
- brainstormingSkill
- browser-automation-expertSkill
- bun-runtime-expertSkill
- chatbot-messaging-expertSkill
- ci-cd-devops-architectSkill
- cloud-hosting-expertSkill
- coderabbitSkill
- compliance-gdpr-privacy-expertSkill
- composable-mach-architectSkill
- context-window-engineerSkill
- cron-scheduler-expertSkill
- data-pipeline-etl-expertSkill
- data-telemetry-expertSkill
- data-visualization-expertSkill
- deep-research-analystSkill
- dependency-upgrade-migratorSkill
- design-system-architectSkill
- desktop-electron-expertSkill
- documentation-site-expertSkill
- doku-mcp-serverSkill
- doku-payment-gatewaySkill
- domain-driven-design-expertSkill
- e2e-testing-expertSkill
- ecommerce-expertSkill
- email-notification-expertSkill
- ephemeral-generative-ui-architectSkill
- ephemeral-wasm-sandbox-executorSkill
- error-resilience-expertSkill
- event-driven-architectSkill
- feature-flag-analytics-expertSkill
- file-upload-media-expertSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
16 rules. About 0 are common, 8 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 48
Recommendation: Use Drizzle ORM for edge-compatible apps and performance-critical systems.
- Very specific: line 51
Use $transaction for atomic operations.
- Very specific: line 52
Avoid N+1 queries by using select and include (with Prisma 5.7+ relationJoins preview) rather than looping over findMany.
- Very specific: line 55
Use drizzle-kit generate for generating SQL and drizzle-kit migrate for deployment.
- Distinctive: line 63
Connection Pooling: Use PgBouncer, Supabase's built-in pooler, or Prisma Accelerate for standard TCP to avoid exhausting connection limits.
- Distinctive: line 70
Never make breaking changes in a single deployment.
- Distinctive: line 71
Phase 1 (Expand): Add the new schema element (column, table) without removing the old one.
- Distinctive: line 72
Phase 2 (Migrate): Update app to write to *both* and read from the new element (with fallback).
- Distinctive: line 73
Phase 3 (Backfill): Run background script to backfill data to new element.
- Distinctive: line 74
Phase 4 (Contract): Remove old application code.
- Very specific: line 83
Write idempotent scripts (CREATE TABLE IF NOT EXISTS).
- Very specific: line 93
HTTP/WebSocket Proxy Pooling: Use neon-http or similar when querying databases from Edge Workers/Functions.
- Very specific: line 112
Check Environment: Ensure supabase/migrations directory exists.
- Very specific: line 117
Write SQL script locally: npx supabase migration new [name] -> writes to supabase/migrations/<timestamp>_[name].sql.
- Very specific: line 118
Test locally: npx supabase migration up or npx supabase db reset.
- Distinctive: line 120
Final Step: If using RLS, explicitly add policies to new tables.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Unified Database & ORM Expert
English | Bahasa Indonesia
<a name="english"></a>
English
Description
Design schemas, select ORMs, execute zero-downtime migrations, optimize queries, and implement edge serverless databases. Covers Prisma 6, Drizzle ORM, TypeORM, Supabase CLI workflows, and Edge DBs (Neon, Cloudflare D1, Turso, Upstash).
Trigger Conditions
- Designing or migrating a production schema (blue-green, canary).
- Choosing between Prisma, Drizzle ORM, or TypeORM.
- Writing complex queries with joins, aggregations, or pagination.
- Optimizing slow queries or N+1 problems.
- Building edge-compatible serverless database connections.
- Executing Supabase migrations and RLS patterns.
- Managing backward-compatible massive data backfills.
Orchestration & Integration
js-backend-expert: For Node/Bun/Deno backend implementations integrating these ORMs.ci-cd-devops-architect: For automated migration deployment steps.supabase-security-expert: For Supabase RLS and security.cloud-hosting-expert: For infrastructure integration.
Core ORM & Query Strategies
ORM Selection Guide
| Criteria | Prisma 6 | Drizzle ORM | TypeORM |
| Type Safety | Schema-generated types | SQL-like, inferred types | Decorator-based |
| Bundle Size | Heavy (binary client) | Lightweight (<35KB) | Medium |
| Query Style | Fluent ORM API | SQL-first, composable | ActiveRecord / QueryBuilder |
| Edge Runtime | Prisma Accelerate needed | Native edge support | No |
| Migrations | prisma migrate dev | drizzle-kit push/migrate | synchronize (dev only) |
Recommendation: Use Drizzle ORM for edge-compatible apps and performance-critical systems. Use Prisma 6 for teams preferring a schema-first DX.
Prisma 6 Best Practices
- Use
$transactionfor atomic operations. - Avoid N+1 queries by using
selectandinclude(with Prisma 5.7+ relationJoins preview) rather than looping overfindMany.
Drizzle ORM Best Practices
- Use
drizzle-kit generatefor generating SQL anddrizzle-kit migratefor deployment. - Utilize native edge support and type-safe query builders with
drizzle-orm.
Query Optimization Principles
- Always index foreign keys and columns used in
WHERE,ORDER BY, andJOIN. - Use
EXPLAIN ANALYZEto detect sequential scans. - Cursor-based pagination over offset for large datasets.
- Avoid
SELECT *. Batch inserts where possible. - Connection Pooling: Use PgBouncer, Supabase's built-in pooler, or Prisma Accelerate for standard TCP to avoid exhausting connection limits. Alternatively, use HTTP/WebSocket drivers for edge queries.
Zero-Downtime Migrations & Versioning
1. Zero-Downtime Migration Pattern (Expand and Contract)
Never make breaking changes in a single deployment.
- Phase 1 (Expand): Add the new schema element (column, table) without removing the old one.
- Phase 2 (Migrate): Update app to write to both and read from the new element (with fallback).
- Phase 3 (Backfill): Run background script to backfill data to new element.
- Phase 4 (Contract): Remove old application code.
- Phase 5 (Cleanup): Drop old schema element in next deployment.
2. Backward Compatibility Rules
- Never
DROPorRENAMEa column/table in active use. - Add
DEFAULTvalues to newNOT NULLcolumns.
3. Migration Mechanics & Safe Data Backfilling
- Never run
prisma db pushorsynchronize: truein production. Always use immutable version-controlled scripts (e.g.,20260814_add_user_status.sql). - Write idempotent scripts (
CREATE TABLE IF NOT EXISTS). - Chunking: For large tables, perform updates in batches (using
LIMITand sleep intervals) to prevent table locking. Use background jobs (BullMQ/Inngest).
Edge & Serverless Drivers
Exploit serverless DBs for ultra-low latency:
- Neon & Cloudflare D1: Serverless autoscaling Postgres with instant branching; Distributed edge SQLite.
- Embedded Replicas: Sync edge SQLite read-replicas with central cloud DBs.
- HTTP/WebSocket Proxy Pooling: Use
neon-httpor similar when querying databases from Edge Workers/Functions. - Upstash Redis Edge Caching:
import { Redis } from '@upstash/redis';
const redis = new Redis({ url: process.env.UPSTASH_REDIS_REST_URL!, token: process.env.UPSTASH_REDIS_REST_TOKEN! });
export async function getCachedData(key: string) {
let data = await redis.get(key);
if (!data) {
data = await fetchFromDB();
await redis.set(key, data, { ex: 3600 });
}
return data;
}Supabase CLI & MCP Workflow
- Check Environment: Ensure
supabase/migrationsdirectory exists. - Review Available MCP Commands:
- List existing migrations:
mcp_supabase-mcp-server_list_migrationswithproject_id. - Confirm SQL before executing via server directly.
- List existing migrations:
- Execute Command:
- Write SQL script locally:
npx supabase migration new [name]-> writes tosupabase/migrations/<timestamp>_[name].sql. - Test locally:
npx supabase migration upornpx supabase db reset. - Apply remote:
npx supabase db push(or use remote MCPapply_migration).
- Write SQL script locally:
- Final Step: If using RLS, explicitly add policies to new tables. Confirm completion with user.
<a name="bahasa-indonesia"></a>
Bahasa Indonesia
Deskripsi
Rancang skema, pilih ORM, eksekusi migrasi tanpa downtime, optimalkan query, dan implementasikan edge serverless DB. Mencakup Prisma 6, Drizzle, TypeORM, Supabase CLI, dan Edge DBs (Neon, Cloudflare D1, Turso, Upstash).
Kondisi Pemicu
- Merancang atau memigrasikan skema produksi (blue-green, canary).
- Memilih antara Prisma, Drizzle, atau TypeORM.
- Mengoptimalkan query lambat atau masalah N+1.
- Membuat koneksi serverless kompatibel dengan edge.
- Mengeksekusi migrasi Supabase dan pola RLS.
- Mengelola backfill data besar secara backward-compatible.
Integrasi Orkestrasi
js-backend-expert: Untuk implementasi Node/Bun/Deno.ci-cd-devops-architect: Untuk otomatisasi langkah deployment migrasi.supabase-security-expert: Untuk RLS dan keamanan Supabase.cloud-hosting-expert: Untuk integrasi infrastruktur.
Strategi Inti ORM & Query
- Drizzle ORM direkomendasikan untuk aplikasi edge, Prisma 6 untuk DX schema-first.
- Gunakan
$transactiondan batasiSELECT *. - Selalu indeks foreign key dan gunakan pagination berbasis cursor (Cursor-based pagination).
- Connection Pooling: Gunakan pooler bawaan Supabase, PgBouncer, Prisma Accelerate, atau driver HTTP (seperti
neon-http) untuk request edge.
Migrasi Tanpa Downtime & Versioning
- Pola Expand and Contract: Jangan pernah melakukan breaking change dalam satu rilis. Tambah kolom baru, update kode untuk memakai keduanya, backfill data, hapus kode lama, lalu drop kolom lama.
- Jangan gunakan
DROPatauRENAMEpada kolom aktif. KolomNOT NULLbaru harus memiliki nilaiDEFAULT. - Jangan jalankan
prisma db pushatausynchronize: truedi produksi. Gunakan skrip migrasi bertahap (idempoten). - Backfill Aman: Gunakan pemrosesan batch/chunking dengan background job untuk tabel raksasa agar tidak menyebabkan table lock.
Driver Edge & Serverless
- Manfaatkan Neon Serverless Postgres, Cloudflare D1, Turso, atau Upstash Redis (caching).
- Gunakan driver berbasis HTTP/WebSocket di lingkungan Edge Workers untuk mencegah habisnya batas koneksi TCP.
Alur Kerja Supabase CLI & MCP
- Pastikan folder
supabase/migrationsada. - Periksa migrasi dengan
mcp_supabase-mcp-server_list_migrations. - Buat file migrasi lokal dengan
npx supabase migration new [nama]. - Uji lokal dengan
npx supabase migration up. - Deploy remote dengan
npx supabase db pushatau melalui MCP. - Tambahkan kebijakan RLS jika diperlukan. Konfirmasikan sukses ke pengguna.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

