CREATE TABLE "intencion_pago" ( "id" text PRIMARY KEY NOT NULL, "usuario_id" text NOT NULL, "huella" text NOT NULL, "datos" jsonb NOT NULL, "sesion_pago_id" text, "estado" text DEFAULT 'abierta' NOT NULL, "creado_en" timestamp with time zone DEFAULT now() NOT NULL, CONSTRAINT "intencion_pago_sesion_pago_id_unique" UNIQUE("sesion_pago_id") ); --> statement-breakpoint ALTER TABLE "intencion_pago" ADD CONSTRAINT "intencion_pago_usuario_id_usuario_id_fk" FOREIGN KEY ("usuario_id") REFERENCES "public"."usuario"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint CREATE UNIQUE INDEX "intencion_pago_abierta" ON "intencion_pago" USING btree ("usuario_id","huella") WHERE "intencion_pago"."estado" = 'abierta';