CREATE TABLE "custom_kpi_logs" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"tenant_id" uuid NOT NULL,
	"entry_id" uuid NOT NULL,
	"user_id" uuid NOT NULL,
	"log_date" date NOT NULL,
	"value" double precision NOT NULL,
	"note" text,
	"created_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "custom_kpi_logs" ADD CONSTRAINT "custom_kpi_logs_entry_id_custom_kpi_entries_id_fk" FOREIGN KEY ("entry_id") REFERENCES "public"."custom_kpi_entries"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "custom_kpi_logs_entry_idx" ON "custom_kpi_logs" USING btree ("entry_id","log_date");