2.3 KiB
Enum user_status { INACTIVE ONBOARDING ACTIVE SUSPENDED DISABLED }
Enum tenant_status { ACTIVE SUSPENDED DISABLED }
Enum subscription_status { ACTIVE EXPIRED CANCELLED TRIAL }
Table users { id uuid [pk] email varchar(100) [unique] username varchar(20) [unique] password varchar email_verified_at timestamp [null] tenant_id uuid [null] status user_status [default: 'ONBOARDING']
created_at timestamp updated_at timestamp [null] deleted_at timestamp [null]
indexes { (email) [unique] (username) [unique] (tenant_id) (status) } }
Table user_profiles { id uuid [pk] user_id uuid [unique, not null] full_name varchar(200) phone varchar(20) [null] timezone varchar(50) [null, default: 'Asia/Jakarta']
created_at timestamp updated_at timestamp [null] deleted_at timestamp [null]
indexes { (user_id) [unique] } }
Table business_types { id uuid [pk] code varchar(30) [unique] name varchar(100) is_active boolean [default: true] created_at timestamp deleted_at timestamp [null] updated_at timestamp [null]
indexes { (code) [unique] } }
Table plans { id uuid [pk] code varchar(20) [unique] name varchar(100) description text [null] price int limits json [null] is_active boolean [default: true] created_at timestamp updated_at timestamp [null] deleted_at timestamp [null]
indexes { (code) [unique] } }
Table tenants { id uuid [pk] name varchar(200) slug varchar(100) [unique] business_type_id uuid [not null] phone varchar(20) [null] address text [null] email varchar(100) [null] status tenant_status [default: 'ACTIVE']
created_at timestamp updated_at timestamp [null] deleted_at timestamp [null]
indexes { (slug) [unique] (business_type_id) } }
Table subscriptions { id uuid [pk] tenant_id uuid [unique, not null] plan_id uuid [not null] limits json [null] status subscription_status [default: 'TRIAL'] started_at timestamp ended_at timestamp [null] created_at timestamp updated_at timestamp [null]
indexes { (tenant_id) [unique] (plan_id) (status) } }
Ref: user_profiles.user_id > users.id Ref: tenants.business_type_id > business_types.id Ref: subscriptions.tenant_id > tenants.id Ref: subscriptions.plan_id > plans.id Ref: users.tenant_id > tenants.id