Skip to main content

Roles & Module Permissions

Overview​

This domain has four tables: system_role (roles), system_module (system features/modules), system_role_module (what each role may do in each module) and organization_module (which modules an organization has been granted). A user's effective permissions are the intersection of their role grants and the modules enabled for their organization.

Table system_role​

ColumnTypeNullableDefaultDescription
idINTEGERNOT NULLnextval (serial)Primary key of the role
nameTEXTNOT NULL–Role name, e.g. admin, editor, viewer
totalINTEGERNOT NULL5Maximum number of users allowed to hold this role
typeUserType (enum)NOT NULL–Which user type the role applies to: onemoby or customer
statusCommonStatus (enum)NOT NULL–Role status (active, inactive, etc.)
created_dateTIMESTAMPTZ(3)NOT NULLCURRENT_TIMESTAMPCreation timestamp
created_byINTEGERNOT NULL0User id of the creator
updated_dateTIMESTAMPTZ(3)NULL–Last update timestamp
updated_byINTEGERNULL0User id of the last editor
deleted_dateTIMESTAMPTZ(3)NULL–Soft-delete timestamp

Table system_module​

ColumnTypeNullableDefaultDescription
idINTEGERNOT NULLnextval (serial)Primary key of the module
nameTEXTNOT NULL–Module/feature name, e.g. import-mapping, campaign
actionsTEXTNOT NULL–Comma-separated list of actions the module supports, e.g. readAll,read,create,update,delete
statusCommonStatus (enum)NOT NULL–Module status (active = enabled in the system)
created_dateTIMESTAMPTZ(3)NOT NULLCURRENT_TIMESTAMPCreation timestamp
created_byINTEGERNOT NULL0User id of the creator
updated_dateTIMESTAMPTZ(3)NULL–Last update timestamp
updated_byINTEGERNULL0User id of the last editor
deleted_dateTIMESTAMPTZ(3)NULL–Soft-delete timestamp

Table system_role_module​

ColumnTypeNullableDefaultDescription
idINTEGERNOT NULLnextval (serial)Primary key
role_idINTEGERNOT NULL–Role (FK to system_role.id)
module_idINTEGERNOT NULL–Module (FK to system_module.id)
actionsTEXTNOT NULL–Actions this role may perform on this module (a subset of system_module.actions)
created_dateTIMESTAMPTZ(3)NOT NULLCURRENT_TIMESTAMPCreation timestamp
created_byINTEGERNOT NULL0User id of the creator
updated_dateTIMESTAMPTZ(3)NULL–Last update timestamp
updated_byINTEGERNULL0User id of the last editor

Table organization_module​

ColumnTypeNullableDefaultDescription
idINTEGERNOT NULLnextval (serial)Primary key
organization_idINTEGERNOT NULL–Organization (FK to organization.id, ON DELETE CASCADE)
module_idINTEGERNOT NULL–Module (FK to system_module.id, ON DELETE CASCADE)
actionsTEXTNOT NULL–Actions this organization is granted on this module
created_dateTIMESTAMPTZNOT NULLnow()Creation timestamp
updated_dateTIMESTAMPTZNULL–Last update timestamp

Notes​

  • organization_module is absent from schema.prisma and has no tracked migration file — the table was created directly on the database. The structure above comes from the preprod pg_dump (schema-dumps/2026-07-24/schema.sql), which is why it lacks the created_by/updated_by/deleted_date columns the other tables in this domain have, and why its timestamps are plain TIMESTAMPTZ (no precision 3).
  • Unique constraint: organization_module (organization_id, module_id) — one row per module per organization.
  • Foreign keys: system_role_module.role_id -> system_role.id, system_role_module.module_id -> system_module.id, organization_module.organization_id -> organization.id, organization_module.module_id -> system_module.id
  • system_role has an index on deleted_date.
  • The actions column in all three tables is a comma-separated string, not an array or JSON, e.g. readAll,read,create,update,delete. readAll means "see all records in the organization" while read means "see only your own records".
  • Registering a new module requires inserts into system_module, system_role_module (for the relevant roles) and organization_module (for customer organizations that already have overrides). See manual-sql/9.import_mapping.sql for a worked example.