-- CreateTable
CREATE TABLE "vlans" (
    "id" TEXT NOT NULL,
    "omada_vlan_id" TEXT,
    "site_id" TEXT NOT NULL,
    "name" TEXT NOT NULL,
    "vlan_id" INTEGER NOT NULL,
    "subnet" TEXT NOT NULL,
    "gateway" TEXT,
    "dhcp_enabled" BOOLEAN NOT NULL DEFAULT false,
    "description" TEXT,
    "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updated_at" TIMESTAMP(3) NOT NULL,

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

-- CreateIndex
CREATE INDEX "vlans_site_id_idx" ON "vlans"("site_id");

-- CreateIndex
CREATE INDEX "vlans_vlan_id_idx" ON "vlans"("vlan_id");

-- CreateIndex
CREATE INDEX "vlans_omada_vlan_id_idx" ON "vlans"("omada_vlan_id");

-- CreateIndex
CREATE UNIQUE INDEX "vlans_site_id_vlan_id_key" ON "vlans"("site_id", "vlan_id");

-- AddForeignKey
ALTER TABLE "vlans" ADD CONSTRAINT "vlans_site_id_fkey" FOREIGN KEY ("site_id") REFERENCES "sites"("id") ON DELETE CASCADE ON UPDATE CASCADE;
