CREATE TABLE "crm_role_profiles" ( "id" text PRIMARY KEY NOT NULL, "organization_id" text NOT NULL, "code" text NOT NULL, "name" text NOT NULL, "description" text, "permissions" text[] DEFAULT '{}' NOT NULL, "branch_scope_mode" text DEFAULT 'assigned' NOT NULL, "product_scope_mode" text DEFAULT 'assigned' NOT NULL, "ownership_scope" text DEFAULT 'own' NOT NULL, "approval_authority" text DEFAULT 'none' NOT NULL, "is_system" boolean DEFAULT false NOT NULL, "is_active" boolean DEFAULT true 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, "created_by" text NOT NULL, "updated_by" text NOT NULL ); --> statement-breakpoint ALTER TABLE "memberships" ADD COLUMN "branch_scope_ids" text[] DEFAULT '{}' NOT NULL;--> statement-breakpoint ALTER TABLE "memberships" ADD COLUMN "product_type_scope_ids" text[] DEFAULT '{}' NOT NULL;--> statement-breakpoint CREATE UNIQUE INDEX "crm_role_profiles_org_code_idx" ON "crm_role_profiles" USING btree ("organization_id","code");