-- CreateTable
CREATE TABLE "matching_runs" (
    "id" SERIAL NOT NULL,
    "event_id" INTEGER NOT NULL,
    "trigger" VARCHAR(20) NOT NULL,
    "status" VARCHAR(20) NOT NULL DEFAULT 'running',
    "started_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "ended_at" TIMESTAMP(3),
    "matched_count" INTEGER NOT NULL DEFAULT 0,
    "not_found_count" INTEGER NOT NULL DEFAULT 0,
    "error" TEXT,

    CONSTRAINT "matching_runs_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "matching_runs_event_id_started_at_idx" ON "matching_runs"("event_id", "started_at");

-- AddForeignKey
ALTER TABLE "matching_runs" ADD CONSTRAINT "matching_runs_event_id_fkey" FOREIGN KEY ("event_id") REFERENCES "events"("id") ON DELETE CASCADE ON UPDATE CASCADE;

