Organizations & Plans
Overview
This domain holds the top-level tenant of the platform: the organization, which represents a single customer subscribed to LINE Management. Everything else in the system — LINE OAs, CMS users, campaigns, audiences — hangs off an organization. That is why an organization_id column appears in almost every table: it is the guard that keeps data from leaking across tenants.
Beyond the organization record itself, this domain also covers the usage quotas (plan limits) that the platform admin (1Moby) assigns to each organization, the reusable plan templates, and the platform admin audit log.
Core Data Structure
organization (Prisma model Organization)
The main organization table carries id, name, logo, status (enum CommonStatus) plus the quota columns:
max_channel(default 5) — the maximum number of LINE OAs the organization may createplan_limitsJSONB — added later through manual SQL, so it does not appear inschema.prisma. Values look like{"maxSegments":-1,"maxActiveWorkflows":-1,"maxTemplates":-1,"maxAttributes":-1,"autoRefresh":true}, where-1means unlimited andNULLmeans fall back to the platform default- Standard audit columns:
created_date/created_by/updated_date/updated_by/deleted_date(soft delete)
The organization has a 1 : N relationship with line_oa, user, campaign, tracking_log and friend_track_campaign.
Supporting tables created via manual SQL
| Table | Purpose |
|---|---|
admin_plan | Plan templates a platform admin can apply to an organization. Holds name, module_ids JSONB (enabled modules) and caps JSONB (usage ceilings). |
admin_audit_log | Records every platform-admin action via actor, action, organization_id, detail JSONB and created_at. An index on (organization_id, created_at DESC) backs the per-organization audit page. |
organization_module | Overrides which modules a given organization has enabled, keyed by (organization_id, module_id, actions). Works alongside system_role_module. |
How quotas cascade
Each LINE OA carries its own plan_limits JSONB (line_oa.plan_limits, default '{}'). Quota counters read the channel-level value first; if it is empty they fall back to the organization value, and finally to the platform default.
Related Files
prisma/schema.prisma:192— modelOrganizationmanual-sql/7.plan_limits.sql— addsorganization.plan_limitsand grants unlimited quotas to organization id 1 (1Moby)prisma/migrations/20260726180000_add_line_oa_plan_limits/migration.sql— theline_oa.plan_limitscolumnprisma/migrations/20260727090000_add_admin_audit_and_plan/migration.sql—admin_audit_logandadmin_planseed-data/04.organization.sql— seeds the first organization, "1Moby" (id 1)schema-dumps/2026-07-24/schema.sql:2384— the live preprod structureschema-dumps/2026-07-24/schema.sql:2423—organization_module
Connections to Other Services
- cms-api-go — reads and writes these tables through the platform admin screens: onboarding new organizations, setting plan limits, and toggling modules per organization. It also uses
plan_limitsas a guard when creating audiences, workflows, templates and attributes. - Every service — scopes its queries by
organization_idto preserve multi-tenant isolation. - Connects to LINE Official Account (one organization to many channels, capped by
max_channel), CMS Users and Roles & Module Permissions.