50 lines
1.6 KiB
SQL
50 lines
1.6 KiB
SQL
CREATE TABLE "crm_enquiries" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"organization_id" text NOT NULL,
|
|
"branch_id" text,
|
|
"code" text NOT NULL,
|
|
"customer_id" text NOT NULL,
|
|
"contact_id" text,
|
|
"title" text NOT NULL,
|
|
"description" text,
|
|
"requirement" text,
|
|
"project_name" text,
|
|
"project_location" text,
|
|
"product_type" text NOT NULL,
|
|
"status" text NOT NULL,
|
|
"priority" text NOT NULL,
|
|
"lead_channel" text,
|
|
"estimated_value" double precision,
|
|
"chance_percent" integer,
|
|
"expected_close_date" timestamp with time zone,
|
|
"competitor" text,
|
|
"source" text,
|
|
"notes" text,
|
|
"is_hot_project" 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
|
|
CREATE TABLE "crm_enquiry_followups" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"organization_id" text NOT NULL,
|
|
"enquiry_id" text NOT NULL,
|
|
"followup_date" timestamp with time zone NOT NULL,
|
|
"followup_type" text NOT NULL,
|
|
"contact_id" text,
|
|
"outcome" text,
|
|
"notes" text,
|
|
"next_followup_date" timestamp with time zone,
|
|
"next_action" 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,
|
|
"created_by" text NOT NULL,
|
|
"updated_by" text NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "crm_enquiries_org_code_idx" ON "crm_enquiries" USING btree ("organization_id","code"); |