CREATE TYPE "public"."guest_type" AS ENUM('adult', 'child');--> statement-breakpoint CREATE TYPE "public"."rsvp_status" AS ENUM('pending', 'confirmed', 'declined');--> statement-breakpoint CREATE TABLE "events" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "name" text NOT NULL, "date" date NOT NULL, "time" time NOT NULL, "venue" text NOT NULL, "address" text NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "guests" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "invitation_id" uuid NOT NULL, "name" text NOT NULL, "type" "guest_type" NOT NULL, "status" "rsvp_status" DEFAULT 'pending' NOT NULL, "sort_order" integer DEFAULT 0 NOT NULL, "responded_at" timestamp with time zone ); --> statement-breakpoint CREATE TABLE "invitations" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "event_id" uuid NOT NULL, "token" text NOT NULL, "display_name" text NOT NULL, "responded_at" timestamp with time zone, "created_at" timestamp with time zone DEFAULT now() NOT NULL, CONSTRAINT "invitations_token_unique" UNIQUE("token") ); --> statement-breakpoint ALTER TABLE "guests" ADD CONSTRAINT "guests_invitation_id_invitations_id_fk" FOREIGN KEY ("invitation_id") REFERENCES "public"."invitations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "invitations" ADD CONSTRAINT "invitations_event_id_events_id_fk" FOREIGN KEY ("event_id") REFERENCES "public"."events"("id") ON DELETE cascade ON UPDATE no action;