52 lines
1.5 KiB
SQL
52 lines
1.5 KiB
SQL
CREATE TABLE "crm_customer_contacts" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"organization_id" text NOT NULL,
|
|
"customer_id" text NOT NULL,
|
|
"name" text NOT NULL,
|
|
"position" text,
|
|
"department" text,
|
|
"phone" text,
|
|
"mobile" text,
|
|
"email" text,
|
|
"is_primary" boolean DEFAULT false NOT NULL,
|
|
"notes" text,
|
|
"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_customers" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"organization_id" text NOT NULL,
|
|
"branch_id" text,
|
|
"code" text NOT NULL,
|
|
"name" text NOT NULL,
|
|
"abbr" text,
|
|
"tax_id" text,
|
|
"customer_type" text NOT NULL,
|
|
"customer_status" text NOT NULL,
|
|
"address" text,
|
|
"province" text,
|
|
"district" text,
|
|
"sub_district" text,
|
|
"postal_code" text,
|
|
"country" text,
|
|
"phone" text,
|
|
"fax" text,
|
|
"email" text,
|
|
"website" text,
|
|
"lead_channel" text,
|
|
"customer_group" text,
|
|
"notes" text,
|
|
"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 UNIQUE INDEX "crm_customers_org_code_idx" ON "crm_customers" USING btree ("organization_id","code"); |