CREATE TABLE "dealer_inactive_notes" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"tenant_id" uuid NOT NULL,
	"customer_id" uuid NOT NULL,
	"period_key" text NOT NULL,
	"reason" text NOT NULL,
	"recorded_by" uuid,
	"recorded_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "dealer_inactive_notes" ADD CONSTRAINT "dealer_inactive_notes_customer_id_customers_id_fk" FOREIGN KEY ("customer_id") REFERENCES "public"."customers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE UNIQUE INDEX "dealer_inactive_notes_uniq" ON "dealer_inactive_notes" USING btree ("customer_id","period_key");--> statement-breakpoint
CREATE INDEX "dealer_inactive_notes_period_idx" ON "dealer_inactive_notes" USING btree ("tenant_id","period_key");