องค์กรและแพ็กเกจการใช้งาน
ภาพรวม
Domain นี้เก็บ ผู้เช่าระบบระดับบนสุด (tenant) คือ organization ซึ่งหมายถึงลูกค้า 1 รายที่สมัครใช้ LINE Management ข้อมูลทุกอย่างในระบบ ไม่ว่าจะเป็น LINE OA, ผู้ใช้ CMS, campaign หรือ audience จะแขวนอยู่ใต้องค์กรเสมอ คอลัมน์ organization_id จึงปรากฏอยู่แทบทุกตาราง เพื่อป้องกันข้อมูลรั่วไหลข้าม tenant
นอกจากตัวองค์กรเองแล้ว domain นี้ยังดูแล โควตาการใช้งาน (plan limits) ที่ platform admin (1Moby) กำหนดให้แต่ละองค์กร, แม่แบบแพ็กเกจ ที่นำไปใช้ซ้ำได้ และ audit log ของ platform admin
โครงสร้างข้อมูลหลัก
organization (Prisma model Organization)
ตารางหลักขององค์กร ประกอบด้วย id, name, logo, status (enum CommonStatus) พร้อมคอลัมน์ควบคุมโควตา
max_channel(default 5) — จำนวน LINE OA สูงสุดที่องค์กรสร้างได้plan_limitsJSONB — เพิ่มภายหลังด้วย manual SQL จึงไม่ปรากฏในschema.prismaรูปแบบค่าเป็น{"maxSegments":-1,"maxActiveWorkflows":-1,"maxTemplates":-1,"maxAttributes":-1,"autoRefresh":true}โดย-1หมายถึงไม่จำกัด และค่าNULLหมายถึงให้ใช้ค่า default ของแพลตฟอร์ม- audit columns มาตรฐาน
created_date/created_by/updated_date/updated_by/deleted_date(soft delete)
ความสัมพันธ์เป็นแบบ 1 : N กับ line_oa, user, campaign, tracking_log และ friend_track_campaign
ตารางเสริมที่สร้างด้วย manual SQL
| ตาราง | หน้าที่ |
|---|---|
admin_plan | แม่แบบแพ็กเกจที่ platform admin เลือกใช้กับองค์กรได้ เก็บ name, module_ids JSONB (โมดูลที่เปิด) และ caps JSONB (เพดานการใช้งาน) |
admin_audit_log | บันทึกทุกการกระทำของ platform admin ผ่าน actor, action, organization_id, detail JSONB และ created_at มี index (organization_id, created_at DESC) รองรับหน้า audit รายองค์กร |
organization_module | override ว่าองค์กรนี้เปิดใช้โมดูลใดบ้าง ด้วยคู่ (organization_id, module_id, actions) ทำงานคู่กับ system_role_module |
การซ้อนชั้นของโควตา
ระดับ LINE OA มีคอลัมน์ plan_limits JSONB ของตัวเองด้วย (line_oa.plan_limits, default '{}') ตัวนับโควตาจะอ่านค่าของ channel ก่อน ถ้าไม่พบจึงถอยไปใช้ค่าขององค์กร และสุดท้ายจึงใช้ค่า default ของแพลตฟอร์ม
ไฟล์ที่เกี่ยวข้อง
prisma/schema.prisma:192— modelOrganizationmanual-sql/7.plan_limits.sql— เพิ่มคอลัมน์organization.plan_limitsและตั้งค่าไม่จำกัดให้องค์กร id 1 (1Moby)prisma/migrations/20260726180000_add_line_oa_plan_limits/migration.sql— คอลัมน์line_oa.plan_limitsprisma/migrations/20260727090000_add_admin_audit_and_plan/migration.sql— ตารางadmin_audit_logและadmin_planseed-data/04.organization.sql— seed องค์กรแรก "1Moby" (id 1)schema-dumps/2026-07-24/schema.sql:2384— โครงสร้างจริงบน preprodschema-dumps/2026-07-24/schema.sql:2423— ตารางorganization_module
จุดเชื่อมต่อกับ Service อื่น
- cms-api-go — อ่านและเขียนผ่านหน้า platform admin สำหรับ onboarding องค์กรใหม่ ตั้งค่า plan limits และเปิด/ปิดโมดูลรายองค์กร นอกจากนี้ยังใช้
plan_limitsเป็น guard ตอนสร้าง audience, workflow, template และ attribute - ทุก service — ใช้
organization_idเป็น scope หลักในการ query เพื่อรักษา multi-tenant isolation - เชื่อมกับ LINE Official Account (1 องค์กรต่อหลาย channel จำกัดด้วย
max_channel), ผู้ใช้งาน CMS และ บทบาทและสิทธิ์