-- CreateTable
CREATE TABLE "Device" (
    "id" TEXT NOT NULL PRIMARY KEY,
    "serialNumber" TEXT NOT NULL,
    "macAddress" TEXT NOT NULL,
    "name" TEXT DEFAULT 'Unnamed Device',
    "status" TEXT NOT NULL DEFAULT 'PENDING',
    "lastHeartbeat" DATETIME,
    "uptime" INTEGER,
    "temperature" REAL,
    "activeSlot" TEXT NOT NULL DEFAULT 'A',
    "firmwareVersion" TEXT NOT NULL DEFAULT '1.0.0',
    "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" DATETIME NOT NULL
);

-- CreateTable
CREATE TABLE "Test" (
    "id" TEXT NOT NULL PRIMARY KEY,
    "deviceId" TEXT NOT NULL,
    "timestamp" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "type" TEXT NOT NULL,
    "status" TEXT NOT NULL,
    "hdmi5v" BOOLEAN NOT NULL,
    "edid1080p" BOOLEAN,
    "edid4k120" BOOLEAN,
    "diodeResults" TEXT,
    "rawOutput" TEXT,
    "summary" TEXT NOT NULL,
    CONSTRAINT "Test_deviceId_fkey" FOREIGN KEY ("deviceId") REFERENCES "Device" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);

-- CreateIndex
CREATE UNIQUE INDEX "Device_serialNumber_key" ON "Device"("serialNumber");

-- CreateIndex
CREATE UNIQUE INDEX "Device_macAddress_key" ON "Device"("macAddress");
