-- AlterEnum
ALTER TYPE "LicitationSource" ADD VALUE IF NOT EXISTS 'MUNICIPAL_OPEN_PORTAL';

-- CreateEnum
CREATE TYPE "MunicipalOpenPortalType" AS ENUM ('GENERIC', 'SAN_PEDRO_ASPX');

-- AlterTable
ALTER TABLE "Municipality"
ADD COLUMN "openPortalUrl" TEXT,
ADD COLUMN "openPortalType" "MunicipalOpenPortalType" NOT NULL DEFAULT 'GENERIC',
ADD COLUMN "openSyncIntervalDays" INTEGER NOT NULL DEFAULT 7,
ADD COLUMN "lastOpenSyncAt" TIMESTAMP(3);

-- AlterTable
ALTER TABLE "Licitation"
ADD COLUMN "tenderCode" TEXT,
ADD COLUMN "isOpen" BOOLEAN NOT NULL DEFAULT true,
ADD COLUMN "openingDate" TIMESTAMP(3),
ADD COLUMN "closingDate" TIMESTAMP(3),
ADD COLUMN "lastSeenAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;

-- CreateIndex
CREATE INDEX "Licitation_municipalityId_isOpen_closingDate_idx" ON "Licitation"("municipalityId", "isOpen", "closingDate");
