-- AlterTable
ALTER TABLE "child_profiles" ADD COLUMN     "age" INTEGER NOT NULL DEFAULT 0,
ADD COLUMN     "gradeId" TEXT;

-- CreateTable
CREATE TABLE "device_invites" (
    "id" TEXT NOT NULL,
    "code" TEXT NOT NULL,
    "parentId" TEXT NOT NULL,
    "expiresAt" TIMESTAMP(3) NOT NULL,
    "usedAt" TIMESTAMP(3),
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateIndex
CREATE UNIQUE INDEX "device_invites_code_key" ON "device_invites"("code");

-- AddForeignKey
ALTER TABLE "device_invites" ADD CONSTRAINT "device_invites_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
