specs / 020-Changes-Ops-Cleanup-Rent-Group

020 - Ops cleanup + schema UUID/FK hygiene

  • Tanggal: 2026-08-11
  • Chat/topik: Keep item_* names; delete misleading Rent/ProShop group; audit core integrity (migration 015)

Ringkasan perubahan

  • Hapus item_groups GRP-MER-RNT (Rent + ProShop); ganti dengan GRP-RENT-GEAR (product_type=Rent).
  • Hard-delete POS devices revoked/debug/smoke (prod: sisa Kasir + POS-FNB).
  • store_settings.default_branch_id → MAIN; conventions clarify store vs branch.
  • Seed review + sync fact_review (local + prod).
  • item_* tables not renamed.
  • Migration 015: semua *_id / deleted_byuuid; FK + index FK; drop 10 enum mati; ANALYZE. Legacy transaction_items.reference_id berawalan court- dinormalisasi.
  • Migration 016 (hardening high-traffic): exclusion constraint bookings_no_overlap (btree_gist) anti double-booking; CHECK stock_quantity >= 0; index bookings(court_id, start_time); drop 2 index redundant; sisa FK index; rename ksrdb.owner_usersusers.
  • mpc-be hardening: stok atomic (DeductStock guard WHERE); voucher redeem guarded (current_uses < max_uses); CompleteTransaction idempotent + transaksi DB (payment_events/stock_ledger tidak pernah dobel); booking insert map error constraint → "booking conflict"; pool limits + logger Warn (mpc-be & mpc-be-pos).

Impact bisnis

Katalog admin tidak lagi menampilkan group Rent palsu di ProShop; integritas referensi OLTP lebih ketat (FK + uuid).

Epic / User stories

  • US: Sebagai admin, saya tidak melihat group Rent di bawah ProShop.
  • US: Sebagai sistem, semua identifier relasional bertipe uuid dan terindeks.

User terdampak

Admin, kasir POS (device list bersih), owner (fact_review); member apps tidak berubah API.

Aplikasi terdampak

  • mpc-admin: PERLU — Prisma @db.Uuid alignment
  • mpc-be: PERLU — gorm type:uuid tags + hardening race condition (non-breaking API)
  • mpc-be-pos: PERLU — gorm tag reference_id uuid + pool limits
  • mpc-owner: PERLU — Prisma @@map("users") (rename ksrdb)
  • ksr-sync: PERLU — mirror Prisma @@map("users")
  • mpc-pos / android / ios / web: TIDAK — tidak ada perubahan API/perilaku

Perubahan schema

Migration 014, 015, 016.

Perubahan kode

  • Admin: Prisma StoreSettings/Staff/TimeGroup/SpecialDay/TransactionItem.
  • mpc-be: gorm uuid tags; inventory.DeductStock atomic; voucher redeem guarded (orders); CompleteTransaction idempotent + tx DB (transactions); error mapping bookings_no_overlap; pool limits + logger Warn.
  • mpc-be-pos: gorm uuid tag; pool limits + logger Warn.
  • mpc-owner & ksr-sync: @@map("users").