This commit is contained in:
phaichayon
2026-06-22 10:59:31 +07:00
parent b154a8de33
commit 771ebfc308
23 changed files with 6113 additions and 39 deletions

View File

@@ -0,0 +1,20 @@
CREATE TABLE IF NOT EXISTS "crm_user_role_assignments" (
"id" text PRIMARY KEY NOT NULL,
"organization_id" text NOT NULL,
"user_id" text NOT NULL,
"role_profile_id" text NOT NULL,
"branch_scope_mode" text DEFAULT 'inherit' NOT NULL,
"branch_scope_ids" text[] DEFAULT '{}' NOT NULL,
"product_type_scope_mode" text DEFAULT 'inherit' NOT NULL,
"product_type_scope_ids" text[] DEFAULT '{}' NOT NULL,
"is_primary" boolean DEFAULT false NOT NULL,
"is_active" boolean DEFAULT true NOT NULL,
"assigned_by" text NOT NULL,
"assigned_at" timestamp with time zone DEFAULT now() NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
"deleted_at" timestamp with time zone
);
CREATE UNIQUE INDEX IF NOT EXISTS "crm_user_role_assignments_org_user_role_idx"
ON "crm_user_role_assignments" ("organization_id", "user_id", "role_profile_id");