61 lines
2.9 KiB
SQL
61 lines
2.9 KiB
SQL
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"); |