Skip to main content

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 create
  • plan_limits JSONB — added later through manual SQL, so it does not appear in schema.prisma. Values look like {"maxSegments":-1,"maxActiveWorkflows":-1,"maxTemplates":-1,"maxAttributes":-1,"autoRefresh":true}, where -1 means unlimited and NULL means 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

TablePurpose
admin_planPlan templates a platform admin can apply to an organization. Holds name, module_ids JSONB (enabled modules) and caps JSONB (usage ceilings).
admin_audit_logRecords 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_moduleOverrides 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.

  • prisma/schema.prisma:192 — model Organization
  • manual-sql/7.plan_limits.sql — adds organization.plan_limits and grants unlimited quotas to organization id 1 (1Moby)
  • prisma/migrations/20260726180000_add_line_oa_plan_limits/migration.sql — the line_oa.plan_limits column
  • prisma/migrations/20260727090000_add_admin_audit_and_plan/migration.sqladmin_audit_log and admin_plan
  • seed-data/04.organization.sql — seeds the first organization, "1Moby" (id 1)
  • schema-dumps/2026-07-24/schema.sql:2384 — the live preprod structure
  • schema-dumps/2026-07-24/schema.sql:2423organization_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_limits as a guard when creating audiences, workflows, templates and attributes.
  • Every service — scopes its queries by organization_id to preserve multi-tenant isolation.
  • Connects to LINE Official Account (one organization to many channels, capped by max_channel), CMS Users and Roles & Module Permissions.