Preferred DB: PostgreSQL
Default untuk semua project backend (Go, Laravel, NestJS, Bun/Hono).
Schema Design
- Use snake_case untuk nama tabel dan kolom.
- Tabel plural:
users,posts,orders. - Foreign key naming:
user_id,post_id. - Timestamps:
created_at,updated_at,deleted_at(soft delete jika perlu). - UUID primary key untuk distributed systems, SERIAL/BIGINT untuk single-node.
Migration Strategy
Gunakan migration tool sesuai stack:
| Stack | Tool |
|---|---|
| Go | Atlas / goose |
| Laravel | Eloquent migrations |
| NestJS | TypeORM / Prisma |
| Bun | Drizzle ORM |
Indexing
- Index kolom yang sering di-
WHERE,JOIN,ORDER BY. - Pertimbangkan partial index untuk query dengan
WHERE status = 'active'. - Cek dengan
EXPLAIN ANALYZEsebelum deploy.
Soft Delete
Pakai deleted_at timestamp NULL DEFAULT NULL.
Query default pakai WHERE deleted_at IS NULL.
Connection Pool
- Go:
SetMaxOpenConns(25),SetMaxIdleConns(10). - NestJS/Prisma: Default pool cukup, adjust berdasarkan load.