diff --git a/prisma/migrations/20250402200144_initial_state/migration.sql b/prisma/migrations/20250402200144_initial_state/migration.sql new file mode 100644 index 0000000..a8c7ac1 --- /dev/null +++ b/prisma/migrations/20250402200144_initial_state/migration.sql @@ -0,0 +1,56 @@ +-- 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; diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml new file mode 100644 index 0000000..648c57f --- /dev/null +++ b/prisma/migrations/migration_lock.toml @@ -0,0 +1,3 @@ +# Please do not edit this file manually +# It should be added in your version-control system (e.g., Git) +provider = "postgresql" \ No newline at end of file