From 9c30798e489753d060f82833f64e6b2c159d59d8 Mon Sep 17 00:00:00 2001 From: Joonas Date: Tue, 17 Jan 2023 17:31:44 +0200 Subject: [PATCH] added prisma migration thingy and updated readme --- README.md | 2 +- .../20230117152854_current/migration.sql | 22 +++++++++++++++++++ prisma/migrations/migration_lock.toml | 3 +++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 prisma/migrations/20230117152854_current/migration.sql create mode 100644 prisma/migrations/migration_lock.toml diff --git a/README.md b/README.md index fb16ec1..ec2be6a 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Set DATABASE_URL with .env git clone https://git.disroot.org/qwertyasdfgh/imageboard cd imageboard pnpm install -pnpm prisma db push +pnpm prisma migrate dev pnpm run build pnpm start ``` diff --git a/prisma/migrations/20230117152854_current/migration.sql b/prisma/migrations/20230117152854_current/migration.sql new file mode 100644 index 0000000..49deca5 --- /dev/null +++ b/prisma/migrations/20230117152854_current/migration.sql @@ -0,0 +1,22 @@ +-- CreateTable +CREATE TABLE "Thread" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "title" TEXT NOT NULL, + "post" TEXT NOT NULL, + "imageName" TEXT NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); + +-- CreateTable +CREATE TABLE "Post" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "comment" TEXT NOT NULL, + "imageName" TEXT, + "replyingTo" INTEGER, + "postId" INTEGER NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + CONSTRAINT "Post_replyingTo_fkey" FOREIGN KEY ("replyingTo") REFERENCES "Post" ("id") ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT "Post_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Thread" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml new file mode 100644 index 0000000..e5e5c47 --- /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 (i.e. Git) +provider = "sqlite" \ No newline at end of file