SurePhone ERD — Diagram Views & Groups (สำหรับ dbdiagram.io)

enrichment-only (ไม่กระทบ SQL) — TableGroup จัดกลุ่มสีตาม domain · DiagramView แยกมุมมองราย flow ใน dbdiagram.io เลือก view ได้จากเมนูมุมขวาบน


DBML

//// ───────── TableGroups (สีตาม domain) ─────────
TableGroup tg_org [color: #E65100, note: 'กิจการ/บ้าน + ตั้งค่า + นายทุน'] {
  org.businesses
  org.terms_and_conditions
  org.investors
  org.business_settings
  org.form_example_images
}
 
TableGroup tg_staff [color: #6A1B9A, note: 'ผู้ใช้หลังบ้าน + สิทธิ์'] {
  staff.users
  staff.user_businesses
  staff.permissions
  staff.user_permissions
}
 
TableGroup tg_shop [color: #1A237E, note: 'ร้านพาร์ทเนอร์'] {
  shop.shops
  shop.users
  shop.consents
  shop.referral_channels
  shop.partner_status_logs
  shop.partner_reasons
  shop.partner_log_reasons
  shop.grade_config
}
 
TableGroup tg_customer [color: #00897B, note: 'ลูกค้า'] {
  customer.users
  customer.consents
}
 
TableGroup tg_device [color: #2E7D32, note: 'แคตตาล็อกสินค้า'] {
  device.brands
  device.capacities
  device.payment_rates
  device.payment_rate_items
  device.products
  device.product_capacities
}
 
TableGroup tg_sys [color: #455A64, note: 'ระบบ/สนับสนุน'] {
  sys.r2_file
  sys.r2_file_cleanup_jobs
  sys.banks
  sys.provinces
  sys.districts
  sys.sub_districts
  sys.portal_settings
}
 
//// ───────── DiagramViews (ราย flow) ─────────
DiagramView full {
  Tables { * }
}
 
// Flow: Super Admin → กิจการ + นายทุน + ตั้งค่า → พนักงาน
DiagramView flow_org_setup {
  Tables {
    org.businesses
    org.investors
    org.terms_and_conditions
    org.business_settings
    org.form_example_images
    staff.users
    staff.user_businesses
    staff.permissions
    staff.user_permissions
    sys.portal_settings
    sys.r2_file
  }
}
 
// Flow: สมัคร + พิจารณาร้านพาร์ทเนอร์
DiagramView flow_shop_onboarding {
  Tables {
    shop.shops
    shop.users
    shop.consents
    shop.referral_channels
    shop.partner_status_logs
    shop.partner_reasons
    shop.partner_log_reasons
    shop.grade_config
    org.businesses
    org.terms_and_conditions
    sys.banks
    sys.sub_districts
    sys.r2_file
  }
}
 
// Flow: ลูกค้า (สมัคร/consent)
DiagramView flow_customer {
  Tables {
    customer.users
    customer.consents
    org.businesses
    org.terms_and_conditions
    shop.shops
  }
}
 
// Flow: สร้างสินค้า/รุ่น + ราคา/เรท
DiagramView flow_device_product {
  Tables {
    device.brands
    device.capacities
    device.payment_rates
    device.payment_rate_items
    device.products
    device.product_capacities
    org.businesses
  }
}
 
// มุมมอง: ตารางระบบ/อ้างอิง
DiagramView view_sys_reference {
  Tables {
    sys.r2_file
    sys.r2_file_cleanup_jobs
    sys.banks
    sys.provinces
    sys.districts
    sys.sub_districts
    sys.portal_settings
  }
}

วิธีใช้

  • แปะ SurePhone.dbml (ที่มี block นี้ต่อท้าย) ใน dbdiagram.io → มุมขวาบนจะมี dropdown เลือก DiagramView (full / flow_org_setup / flow_shop_onboarding / flow_customer / flow_device_product / view_sys_reference)
  • TableGroup จะระบายสีตาม domain ในทุก view
  • ปรับ/เพิ่ม view ได้ตามต้องการ — แก้ที่ไฟล์นี้แล้ว regenerate SurePhone.dbml