ALTER TABLE "invoices" ADD COLUMN "interest_id" text;--> statement-breakpoint
ALTER TABLE "invoices" ADD COLUMN "kind" text DEFAULT 'general' NOT NULL;--> statement-breakpoint
ALTER TABLE "interests" ADD COLUMN "outcome" text;--> statement-breakpoint
ALTER TABLE "interests" ADD COLUMN "outcome_reason" text;--> statement-breakpoint
ALTER TABLE "interests" ADD COLUMN "outcome_at" timestamp with time zone;--> statement-breakpoint
ALTER TABLE "invoices" ADD CONSTRAINT "invoices_interest_id_interests_id_fk" FOREIGN KEY ("interest_id") REFERENCES "public"."interests"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "idx_invoices_interest" ON "invoices" USING btree ("port_id","interest_id");--> statement-breakpoint
CREATE INDEX "idx_interests_outcome" ON "interests" USING btree ("port_id","outcome");