From 1c09246d298e22350792fb244aaba56567cdd14b Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Tue, 14 Jul 2026 15:43:57 +0700 Subject: [PATCH] Add DBML schema for users, tenants, subscriptions, and related entities --- DBML.md | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 DBML.md diff --git a/DBML.md b/DBML.md new file mode 100644 index 0000000..b6382e0 --- /dev/null +++ b/DBML.md @@ -0,0 +1,132 @@ +Enum user_status { + 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 \ No newline at end of file