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");