Skip to content

Database Design ​

erupt-tenant itself owns just four tables for tenants and packages; tenants' users, roles and organizations live in erupt-upms's tables, told apart by the tenant_id column. Tables are created on startup — no SQL scripts.

erupt-tenant database design

Tenants and packages (admin-managed) ​

These four tables are maintained on the admin side only and have no tenant column.

TableMain columns
e_tenant_configtenant_id tenant key (generated on creation, ex + 14 random characters) · code enterprise ID (unique) · name · contact · status enabled / locked · expire_date (empty = never) · account admin account · domain · logo · css · js · remark · audit columns
e_tenant_config_packageTenant–package link: tenant_id → e_tenant_config.id, package_id → e_tenant_package.id
e_tenant_packagecode (unique) · name · sort · status · trial_days · remark
e_tenant_package_menuPackage–menu link: role_id → e_tenant_package.id, menu_id → e_upms_menu.id

e_tenant_config.tenant_id is the value written into the tenant_id column of the other tables.

User directory (erupt-upms, per tenant) ​

Carry the tenant column tenant_id: '0' for the platform, the tenant key for a tenant; queries are restricted and inserts stamped automatically.

TableUnique constraint
e_upms_user(tenant_id, account)
e_upms_role(tenant_id, code)
e_upms_org(tenant_id, code)
e_upms_post(tenant_id, code)
e_upms_user_role · e_upms_user_org_head · e_upms_user_org_division · e_upms_role_menuLink tables, following their user / role
e_upms_login_log · e_upms_operate_logLogin log, operate log
e_upms_sso · e_upms_sso_bindSSO providers (unique (tenant_id, code)) and account bindings

See Multi-tenant UPMS for details.

Platform-wide ​

TableDescription
e_upms_menuOne menu table, referenced by packages and roles
e_dict · e_dict_item · e_open_apiData dictionaries, open API

Business tables ​

Business tables extending the TenantBaseModel family or annotated with @EruptTenant carry a tenant field (default tenant_id): the tenant key for tenant rows, NULL for platform rows, isolated by erupt's data proxy. Index the tenant field:

java
@Table(name = "t_student", indexes = @Index(columnList = EruptTenant.TENANT_FIELD))

See Multi-tenant Business Tables for the behavior.

Upgrading from 2.3.x ​

  • e_tenant_menu and t_e_upms_user / t_e_upms_user_role / t_e_upms_role / t_e_upms_role_menu / t_e_upms_org are no longer used; migrate tenant user data into the e_upms_* tables
  • Drop the old single-column unique indexes on account / code by hand, otherwise tenants cannot share accounts or codes

Steps and SQL are in the Upgrade Guide.

Contributors

The avatar of contributor named as YuePeng YuePeng

Changelog

Released under the Apache-2.0 License.