Skip to main content

Organizations & Plans

Overview

This domain contains a single table, organization, the top-level tenant boundary of the system. Every major table carries an organization_id to keep customer data separated. Plan quotas are not stored in a separate table — they live in the max_channel and plan_limits (JSONB) columns of this table.

Table organization

ColumnTypeNullableDefaultDescription
idINTEGERNOT NULLnextval (serial)Primary key of the organization
logoTEXTNULLURL/path of the organization logo
nameTEXTNOT NULLOrganization name
statusCommonStatus (enum)NOT NULLOrganization status (active, inactive, delete, etc.)
max_channelINTEGERNOT NULL5Maximum number of LINE OA channels this organization may create
created_dateTIMESTAMPTZ(3)NOT NULLCURRENT_TIMESTAMPCreation timestamp
created_byINTEGERNOT NULL0User id of the creator
updated_dateTIMESTAMPTZ(3)NULLLast update timestamp (Prisma @updatedAt)
updated_byINTEGERNULL0User id of the last editor
deleted_dateTIMESTAMPTZ(3)NULLSoft-delete timestamp (NULL = not deleted)
plan_limitsJSONBNULLPer-organization quota overrides; NULL = use platform defaults

Notes

  • plan_limits is a column, not a table. It was added later via manual SQL (manual-sql/7.plan_limits.sql) with ALTER TABLE organization ADD COLUMN IF NOT EXISTS plan_limits JSONB, so it does not appear in schema.prisma.
  • The plan_limits payload is a JSON object with these keys (example: the 1Moby platform organization at id = 1): {"maxSegments":-1,"maxActiveWorkflows":-1,"maxTemplates":-1,"maxAttributes":-1,"autoRefresh":true} where -1 means unlimited. Platform defaults live in cms-api at src/plan-limits/plan-limits.constant.ts.
  • The channel quota is not part of plan_limits; it still uses the max_channel column.
  • An index on deleted_date supports queries that exclude soft-deleted rows.
  • This table is referenced by the organization_id foreign key from user, line_oa, campaign, tracking_log, friend_track_campaign and organization_module.
  • Tables admin_plan and admin_audit_log do not exist anywhere in the system — verified against schema.prisma, the preprod pg_dump and all manual SQL files.