CREATE TYPE "public"."contact_kind" AS ENUM('phone', 'email');--> statement-breakpoint
CREATE TABLE "participant_contacts" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"participant_id" uuid NOT NULL,
	"kind" "contact_kind" NOT NULL,
	"value" text NOT NULL,
	"marketing_consent" boolean DEFAULT false NOT NULL,
	"first_seen_at" timestamp with time zone DEFAULT now() NOT NULL,
	"last_seen_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "participant_contacts" ADD CONSTRAINT "participant_contacts_participant_id_participants_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."participants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
CREATE UNIQUE INDEX "participant_contacts_uq" ON "participant_contacts" USING btree ("participant_id","kind","value");--> statement-breakpoint
CREATE INDEX "participant_contacts_value_idx" ON "participant_contacts" USING btree ("kind","value");--> statement-breakpoint
CREATE INDEX "participants_dni_idx" ON "participants" USING btree ("dni");