Loading...
Loading...
Use when designing schema, writing migrations, writing transactions/concurrent code, optimizing queries, reviewing SQL or ORM code, or seeding/testing data for SQLite, MySQL, or PostgreSQL. Covers safety guards for destructive operations (DROP/TRUNCATE/ALTER), schema/data-type mapping across the three dialects, transaction and locking correctness, migration rollback safety, indexing/EXPLAIN-based query optimization, and evidence-based code review. Trigger this whenever a task touches a database connection, schema, SQL statement, or ORM query for any of these three engines.
npx skill4agent add hoangsoft90/ai_skills databaseviewdialects/00-40-PRAGMA table_infoSHOW CREATE TABLE\d+NODE_ENV=production--force| Khi agent nhận yêu cầu | Load các file |
|---|---|
| Tạo bảng / thiết kế schema | |
| ALTER / DROP / migration | |
| Transaction / logic tiền / giao dịch | |
| Query chậm / tối ưu hiệu năng | |
| Code review (bất kỳ) | |
| Seed / test dữ liệu | |
| Cần pattern phổ biến | |
| Mọi DDL nguy hiểm | |
| Feature | SQLite | MySQL 8+ | PostgreSQL 16+ |
|---|---|---|---|
| RETURNING | ✔ | ✔ (8.0.14+) | ✔ |
| JSON | TEXT (qua JSON functions) | JSON | JSONB (luôn dùng) |
| Partial Index | ✔ | ✘ | ✔ |
| Concurrent Index BUILD | ✘ | ✔ (chậm) | |
| DDL in Transaction | Không (implicit commit) | Không (implicit commit) | ✔ (rollback được) |
| ✘ | ✔ | ✔ |
| Native UUID | TEXT | | UUID |
| Generated Identity | | | |
| FK constraint | Cần | Tự động | Tự động |
| ❌ (phải recreate table) | ✔ (hạn chế) | ✔ |
| Materialized View | ✘ | ✘ | ✔ |
| Advisory Lock | ✘ | ✔ ( | ✔ ( |
| Thao tác | Dev / Staging | Production | Ghi chú |
|---|---|---|---|
| Inspect / EXPLAIN / SELECT | ✅ Auto | ✅ Auto | Production bắt buộc |
| Generate migration / DDL | ✅ Output file | ✅ Output file | Chỉ ghi file, không tự execute |
Execute migration ( | ⚠️ Cần | 🛑 Cần human confirm + | |
Execute | ⚠️ Cần | 🛑 Cần human confirm | |
| ⚠️ Cần | ⛔ NEVER tự động | Chỉ khi human gõ rõ lệnh xác nhận, không suy diễn từ "gấp"/"nhanh lên" |
| Seed / fixture data | ✅ | ⛔ NEVER | Xem |
SELECT VERSION()SELECT version()PRAGMA user_versiondatabase-skill/
├── SKILL.md # <-- file này
├── 00-safety.md # Env guard, destructive ops, 3 modes
├── 10-schema-design.md # Schema, constraints, Data Types Matrix
├── 11-transactions.md # Transaction, isolation, ORM boundary
├── 12-concurrency.md # Locking, Deadlock Retry Loop
├── 20-migration.md # Expand-Contract, down.sql, dry-run
├── 21-indexing-query.md # EXPLAIN, cost-based triggers, N+1
├── 30-review.md # Checklist review SQL + ORM
├── 31-testing-seed.md # Seed idempotent + rollback test
├── 40-patterns.md # Decision trees + common patterns
└── dialects/
├── sqlite.md
├── mysql.md
└── postgres.mdNODE_ENVDATABASE_URL