-- CreateTable
CREATE TABLE "Species" (
    "id" TEXT NOT NULL,
    "name" TEXT NOT NULL,
    "candleDay" INTEGER NOT NULL,
    "balutDay" INTEGER NOT NULL,
    "lockdownDay" INTEGER NOT NULL,
    "hatchDay" INTEGER NOT NULL,

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

-- CreateTable
CREATE TABLE "Batch" (
    "id" TEXT NOT NULL,
    "speciesId" TEXT NOT NULL,
    "trayLevel" TEXT NOT NULL,
    "source" TEXT NOT NULL,
    "setDate" TIMESTAMP(3) NOT NULL,
    "calendarConfirmed" BOOLEAN NOT NULL DEFAULT false,
    "initialEggs" INTEGER NOT NULL,
    "fertileEggs" INTEGER,
    "uncertainEggs" INTEGER,
    "hatchedEggs" INTEGER,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

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

-- CreateIndex
CREATE UNIQUE INDEX "Species_name_key" ON "Species"("name");

-- AddForeignKey
ALTER TABLE "Batch" ADD CONSTRAINT "Batch_speciesId_fkey" FOREIGN KEY ("speciesId") REFERENCES "Species"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
