This commit is contained in:
phaichayon
2026-06-22 16:57:02 +07:00
parent 3f28fde39f
commit ffa5de8311
33 changed files with 6706 additions and 101 deletions

View File

@@ -0,0 +1,30 @@
ALTER TABLE "crm_enquiries"
ADD COLUMN IF NOT EXISTS "closed_won_at" timestamp with time zone,
ADD COLUMN IF NOT EXISTS "closed_lost_at" timestamp with time zone,
ADD COLUMN IF NOT EXISTS "closed_by_user_id" text,
ADD COLUMN IF NOT EXISTS "po_number" text,
ADD COLUMN IF NOT EXISTS "po_date" timestamp with time zone,
ADD COLUMN IF NOT EXISTS "po_amount" double precision,
ADD COLUMN IF NOT EXISTS "po_currency" text,
ADD COLUMN IF NOT EXISTS "lost_reason" text,
ADD COLUMN IF NOT EXISTS "lost_competitor" text,
ADD COLUMN IF NOT EXISTS "lost_remark" text;
CREATE TABLE IF NOT EXISTS "crm_enquiry_attachments" (
"id" text PRIMARY KEY NOT NULL,
"organization_id" text NOT NULL,
"enquiry_id" text NOT NULL,
"category" text NOT NULL,
"file_name" text NOT NULL,
"original_file_name" text NOT NULL,
"storage_provider" text NOT NULL,
"storage_key" text NOT NULL,
"file_size" integer,
"file_type" text,
"description" text,
"uploaded_at" timestamp with time zone DEFAULT now() NOT NULL,
"uploaded_by" text 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
);

View File

@@ -0,0 +1,61 @@
CREATE TABLE "crm_contact_shares" (
"id" text PRIMARY KEY NOT NULL,
"organization_id" text NOT NULL,
"contact_id" text NOT NULL,
"shared_to_user_id" text NOT NULL,
"shared_by_user_id" text NOT NULL,
"shared_at" timestamp with time zone DEFAULT now() NOT NULL,
"is_active" boolean DEFAULT true NOT NULL,
"remark" text,
"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
);
--> statement-breakpoint
CREATE TABLE "crm_customer_owner_history" (
"id" text PRIMARY KEY NOT NULL,
"organization_id" text NOT NULL,
"customer_id" text NOT NULL,
"old_owner_user_id" text,
"new_owner_user_id" text,
"changed_by" text NOT NULL,
"changed_at" timestamp with time zone DEFAULT now() NOT NULL,
"remark" text,
"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
);
--> statement-breakpoint
CREATE TABLE "crm_enquiry_attachments" (
"id" text PRIMARY KEY NOT NULL,
"organization_id" text NOT NULL,
"enquiry_id" text NOT NULL,
"category" text NOT NULL,
"file_name" text NOT NULL,
"original_file_name" text NOT NULL,
"storage_provider" text NOT NULL,
"storage_key" text NOT NULL,
"file_size" integer,
"file_type" text,
"description" text,
"uploaded_at" timestamp with time zone DEFAULT now() NOT NULL,
"uploaded_by" text 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
);
--> statement-breakpoint
ALTER TABLE "crm_customers" ADD COLUMN "owner_user_id" text;--> statement-breakpoint
ALTER TABLE "crm_customers" ADD COLUMN "owner_assigned_at" timestamp with time zone;--> statement-breakpoint
ALTER TABLE "crm_customers" ADD COLUMN "owner_assigned_by" text;--> statement-breakpoint
ALTER TABLE "crm_enquiries" ADD COLUMN "closed_won_at" timestamp with time zone;--> statement-breakpoint
ALTER TABLE "crm_enquiries" ADD COLUMN "closed_lost_at" timestamp with time zone;--> statement-breakpoint
ALTER TABLE "crm_enquiries" ADD COLUMN "closed_by_user_id" text;--> statement-breakpoint
ALTER TABLE "crm_enquiries" ADD COLUMN "po_number" text;--> statement-breakpoint
ALTER TABLE "crm_enquiries" ADD COLUMN "po_date" timestamp with time zone;--> statement-breakpoint
ALTER TABLE "crm_enquiries" ADD COLUMN "po_amount" double precision;--> statement-breakpoint
ALTER TABLE "crm_enquiries" ADD COLUMN "po_currency" text;--> statement-breakpoint
ALTER TABLE "crm_enquiries" ADD COLUMN "lost_reason" text;--> statement-breakpoint
ALTER TABLE "crm_enquiries" ADD COLUMN "lost_competitor" text;--> statement-breakpoint
ALTER TABLE "crm_enquiries" ADD COLUMN "lost_remark" text;--> statement-breakpoint
CREATE UNIQUE INDEX "crm_contact_shares_org_contact_shared_user_idx" ON "crm_contact_shares" USING btree ("organization_id","contact_id","shared_to_user_id");

File diff suppressed because it is too large Load Diff

View File

@@ -113,6 +113,20 @@
"when": 1782549600000,
"tag": "0015_customer_ownership_contact_shares",
"breakpoints": true
},
{
"idx": 16,
"version": "7",
"when": 1782795600000,
"tag": "0016_won_lost_lifecycle_governance",
"breakpoints": true
},
{
"idx": 17,
"version": "7",
"when": 1782121929212,
"tag": "0017_short_swordsman",
"breakpoints": true
}
]
}
}