agentleFS
Ardiyanto24Ardiyanto24/modular-monolith-code-guide/.cursor/rules/database-postgres.mdc

modular-monolith-code-guide / rules

Cursor rule0 starsChanged 2 months agoMITView on GitHub

Konvensi skema PostgreSQL, migrasi golang-migrate, boundary data lintas module, dan indexing

The file

Files
database-postgres.mdc
---
description: Konvensi skema PostgreSQL, migrasi golang-migrate, boundary data lintas module, dan indexing
globs: ["migrations/**/*.sql","**/*_model.go","**/*migration*"]
alwaysApply: false
---

# Database PostgreSQL

Panduan lengkap: [`../../references/DATABASE_GUIDE.md`](../../references/DATABASE_GUIDE.md) — baca file itu sebelum menyentuh skema/migrasi.

Ringkasan aturan yang wajib dipatuhi:

- Migrasi ditulis raw SQL lewat `golang-migrate`, format `NNNN_description.up.sql`/`.down.sql` — bukan ORM migration tool otomatis.
- Nama tabel snake_case plural, nama kolom snake_case, FK bersuffix `_id` dan wajib diberi index.
- Primary key `UUID` native (`gen_random_uuid()`), bukan autoincrement integer.
- `created_at`/`updated_at` wajib ada di tiap tabel non-junction, kecuali pengecualian yang didokumentasikan eksplisit.
- Kolom payload/konfigurasi yang memang didesain bebas bentuk (`jsonb`) **dilarang** dipecah jadi kolom terpisah — validasi struktur ada di application layer, bukan di database.
- Satu module **dilarang** mengakses tabel milik module lain secara langsung — lewat interface Go module pemilik data. Tidak ada FK yang menyeberang dua database fisik berbeda.
- Kalau project ini memakai pola multi-tenant dengan database terisolasi per-tenant, baca §0 dan §4 `DATABASE_GUIDE.md` untuk aturan migrasi cetakan/replay — kalau bukan, lewati bagian itu.
- Sebelum melaporkan perubahan skema "selesai", jalankan checklist di §8 `DATABASE_GUIDE.md`.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.