57 lines
1.4 KiB
SQL
57 lines
1.4 KiB
SQL
-- CreateTable
|
|
CREATE TABLE "Post" (
|
|
"id" SERIAL NOT NULL,
|
|
"slug" TEXT NOT NULL,
|
|
"title" TEXT NOT NULL,
|
|
"contentRendered" JSON NOT NULL,
|
|
"contentMarkdown" TEXT NOT NULL,
|
|
"blurb" TEXT NOT NULL,
|
|
"publishedDate" TIMESTAMP(6) NOT NULL,
|
|
"is_draft" BOOLEAN NOT NULL,
|
|
|
|
CONSTRAINT "Post_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "Tag" (
|
|
"id" SERIAL NOT NULL,
|
|
"name" TEXT NOT NULL,
|
|
|
|
CONSTRAINT "Tag_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "User" (
|
|
"id" SERIAL NOT NULL,
|
|
"username" TEXT NOT NULL,
|
|
"password" TEXT NOT NULL,
|
|
|
|
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "_PostToTag" (
|
|
"A" INTEGER NOT NULL,
|
|
"B" INTEGER NOT NULL,
|
|
|
|
CONSTRAINT "_PostToTag_AB_pkey" PRIMARY KEY ("A","B")
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "Post_slug_key" ON "Post"("slug");
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "Tag_name_key" ON "Tag"("name");
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "_PostToTag_B_index" ON "_PostToTag"("B");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "_PostToTag" ADD CONSTRAINT "_PostToTag_A_fkey" FOREIGN KEY ("A") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "_PostToTag" ADD CONSTRAINT "_PostToTag_B_fkey" FOREIGN KEY ("B") REFERENCES "Tag"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|