-- CreateTable
CREATE TABLE "User" (
    "uid" TEXT NOT NULL PRIMARY KEY,
    "email" TEXT NOT NULL,
    "name" TEXT,
    "nickname" TEXT NOT NULL,
    "passwordHash" TEXT NOT NULL,
    "userAuthToken" TEXT NOT NULL,
    "role" TEXT NOT NULL DEFAULT 'USER',
    "status" BOOLEAN NOT NULL DEFAULT false,
    "at_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "at_updated" DATETIME NOT NULL
);

-- CreateTable
CREATE TABLE "Board" (
    "uid" TEXT NOT NULL PRIMARY KEY,
    "user_uid" TEXT NOT NULL,
    "category" TEXT NOT NULL DEFAULT 'free',
    "title" TEXT NOT NULL,
    "content" TEXT NOT NULL,
    "view" INTEGER NOT NULL DEFAULT 0,
    "recommend" INTEGER NOT NULL DEFAULT 0,
    "status" BOOLEAN NOT NULL DEFAULT false,
    "at_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "at_updated" DATETIME NOT NULL,
    CONSTRAINT "Board_user_uid_fkey" FOREIGN KEY ("user_uid") REFERENCES "User" ("uid") ON DELETE RESTRICT ON UPDATE CASCADE
);

-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

-- CreateIndex
CREATE UNIQUE INDEX "User_userAuthToken_key" ON "User"("userAuthToken");
