Files
CRM-LeadRadar/apps/api/drizzle/0005_left_slapstick.sql
T
yuriandClaude Opus 5.5 9749da5ae7 Lead Radar: исходный код
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-25 23:11:04 +04:00

18 lines
1.2 KiB
SQL

CREATE TABLE "client_photos" (
"id" serial PRIMARY KEY NOT NULL,
"client_id" integer NOT NULL,
"company_id" integer NOT NULL,
"content_type" text NOT NULL,
"size" integer NOT NULL,
"data" text NOT NULL,
"uploaded_by_id" integer,
"created_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "clients" ADD COLUMN "household" jsonb;--> statement-breakpoint
ALTER TABLE "leads" ADD COLUMN "features" jsonb;--> statement-breakpoint
ALTER TABLE "listings" ADD COLUMN "features" jsonb;--> statement-breakpoint
ALTER TABLE "client_photos" ADD CONSTRAINT "client_photos_client_id_clients_id_fk" FOREIGN KEY ("client_id") REFERENCES "public"."clients"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "client_photos" ADD CONSTRAINT "client_photos_company_id_companies_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."companies"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "client_photos" ADD CONSTRAINT "client_photos_uploaded_by_id_users_id_fk" FOREIGN KEY ("uploaded_by_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "client_photos_client_idx" ON "client_photos" USING btree ("client_id");