From 7db7b8264f0dd2b9aea111626eba6da124f0be7f Mon Sep 17 00:00:00 2001 From: Aaron William Po Date: Wed, 5 Apr 2023 21:38:36 -0400 Subject: [PATCH] Switch database to cockroach db and remove height on comment card --- components/BeerById/CommentCardBody.tsx | 2 +- .../migrations/20230119014729_/migration.sql | 121 ------------- .../migrations/20230122035226_/migration.sql | 28 --- .../migrations/20230123021558_/migration.sql | 111 ------------ .../migrations/20230123044455_/migration.sql | 29 --- .../migrations/20230127095307_/migration.sql | 12 -- .../migrations/20230129153944_/migration.sql | 12 -- .../migrations/20230203013640_/migration.sql | 8 - .../migrations/20230206001052_/migration.sql | 12 -- .../migrations/20230209085224_/migration.sql | 16 -- .../migrations/20230211021836_/migration.sql | 30 --- .../migrations/20230213214022_/migration.sql | 16 -- .../migrations/20230304185749_/migration.sql | 2 - .../migrations/20230406013055_/migration.sql | 171 ++++++++++++++++++ prisma/migrations/migration_lock.toml | 2 +- prisma/schema.prisma | 2 +- 16 files changed, 174 insertions(+), 400 deletions(-) delete mode 100644 prisma/migrations/20230119014729_/migration.sql delete mode 100644 prisma/migrations/20230122035226_/migration.sql delete mode 100644 prisma/migrations/20230123021558_/migration.sql delete mode 100644 prisma/migrations/20230123044455_/migration.sql delete mode 100644 prisma/migrations/20230127095307_/migration.sql delete mode 100644 prisma/migrations/20230129153944_/migration.sql delete mode 100644 prisma/migrations/20230203013640_/migration.sql delete mode 100644 prisma/migrations/20230206001052_/migration.sql delete mode 100644 prisma/migrations/20230209085224_/migration.sql delete mode 100644 prisma/migrations/20230211021836_/migration.sql delete mode 100644 prisma/migrations/20230213214022_/migration.sql delete mode 100644 prisma/migrations/20230304185749_/migration.sql create mode 100644 prisma/migrations/20230406013055_/migration.sql diff --git a/components/BeerById/CommentCardBody.tsx b/components/BeerById/CommentCardBody.tsx index b7ac458..d9864d0 100644 --- a/components/BeerById/CommentCardBody.tsx +++ b/components/BeerById/CommentCardBody.tsx @@ -69,7 +69,7 @@ const CommentCardBody: React.FC<{ const timeDistance = useTimeDistance(new Date(comment.createdAt)); return ( -
+

diff --git a/prisma/migrations/20230119014729_/migration.sql b/prisma/migrations/20230119014729_/migration.sql deleted file mode 100644 index 2391542..0000000 --- a/prisma/migrations/20230119014729_/migration.sql +++ /dev/null @@ -1,121 +0,0 @@ --- CreateTable -CREATE TABLE "User" ( - "id" TEXT NOT NULL, - "firstName" TEXT NOT NULL, - "lastName" TEXT NOT NULL, - "email" TEXT NOT NULL, - "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMPTZ(3), - CONSTRAINT "User_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "BeerPost" ( - "id" TEXT NOT NULL, - "name" TEXT NOT NULL, - "ibu" DOUBLE PRECISION NOT NULL, - "abv" DOUBLE PRECISION NOT NULL, - "postedById" TEXT NOT NULL, - "breweryId" TEXT NOT NULL, - "typeId" TEXT NOT NULL, - "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMPTZ(3), - CONSTRAINT "BeerPost_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "BeerComment" ( - "id" TEXT NOT NULL, - "beerPostId" TEXT NOT NULL, - "postedById" TEXT NOT NULL, - "content" TEXT NOT NULL, - "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMPTZ(3), - CONSTRAINT "BeerComment_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "BeerType" ( - "id" TEXT NOT NULL, - "name" TEXT NOT NULL, - "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMPTZ(3), - "postedById" TEXT NOT NULL, - CONSTRAINT "BeerType_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "BreweryPost" ( - "id" TEXT NOT NULL, - "name" TEXT NOT NULL, - "location" TEXT NOT NULL, - "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMPTZ(3), - "postedById" TEXT NOT NULL, - CONSTRAINT "BreweryPost_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "BreweryComment" ( - "id" TEXT NOT NULL, - "breweryPostId" TEXT NOT NULL, - "postedById" TEXT NOT NULL, - "content" TEXT NOT NULL, - "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMPTZ(3), - CONSTRAINT "BreweryComment_pkey" PRIMARY KEY ("id") -); - --- AddForeignKey -ALTER TABLE - "BeerPost" -ADD - CONSTRAINT "BeerPost_postedById_fkey" FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE - "BeerPost" -ADD - CONSTRAINT "BeerPost_breweryId_fkey" FOREIGN KEY ("breweryId") REFERENCES "BreweryPost"("id") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE - "BeerPost" -ADD - CONSTRAINT "BeerPost_typeId_fkey" FOREIGN KEY ("typeId") REFERENCES "BeerType"("id") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE - "BeerComment" -ADD - CONSTRAINT "BeerComment_beerPostId_fkey" FOREIGN KEY ("beerPostId") REFERENCES "BeerPost"("id") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE - "BeerComment" -ADD - CONSTRAINT "BeerComment_postedById_fkey" FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE - "BeerType" -ADD - CONSTRAINT "BeerType_postedById_fkey" FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE - "BreweryPost" -ADD - CONSTRAINT "BreweryPost_postedById_fkey" FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE - "BreweryComment" -ADD - CONSTRAINT "BreweryComment_breweryPostId_fkey" FOREIGN KEY ("breweryPostId") REFERENCES "BreweryPost"("id") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE - "BreweryComment" -ADD - CONSTRAINT "BreweryComment_postedById_fkey" FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; \ No newline at end of file diff --git a/prisma/migrations/20230122035226_/migration.sql b/prisma/migrations/20230122035226_/migration.sql deleted file mode 100644 index 88aba56..0000000 --- a/prisma/migrations/20230122035226_/migration.sql +++ /dev/null @@ -1,28 +0,0 @@ -/* - Warnings: - - - Added the required column `description` to the `BeerPost` table without a default value. This is not possible if the table is not empty. - - Added the required column `description` to the `BreweryPost` table without a default value. This is not possible if the table is not empty. - - Added the required column `dateOfBirth` to the `User` table without a default value. This is not possible if the table is not empty. - - Added the required column `username` to the `User` table without a default value. This is not possible if the table is not empty. - - */ --- AlterTable -ALTER TABLE - "BeerPost" -ADD - COLUMN "description" TEXT NOT NULL; - --- AlterTable -ALTER TABLE - "BreweryPost" -ADD - COLUMN "description" TEXT NOT NULL; - --- AlterTable -ALTER TABLE - "User" -ADD - COLUMN "dateOfBirth" TIMESTAMP(3) NOT NULL, -ADD - COLUMN "username" TEXT NOT NULL; \ No newline at end of file diff --git a/prisma/migrations/20230123021558_/migration.sql b/prisma/migrations/20230123021558_/migration.sql deleted file mode 100644 index 6552d6f..0000000 --- a/prisma/migrations/20230123021558_/migration.sql +++ /dev/null @@ -1,111 +0,0 @@ --- DropForeignKey -ALTER TABLE - "BeerComment" DROP CONSTRAINT "BeerComment_beerPostId_fkey"; - --- DropForeignKey -ALTER TABLE - "BeerComment" DROP CONSTRAINT "BeerComment_postedById_fkey"; - --- DropForeignKey -ALTER TABLE - "BeerPost" DROP CONSTRAINT "BeerPost_breweryId_fkey"; - --- DropForeignKey -ALTER TABLE - "BeerPost" DROP CONSTRAINT "BeerPost_postedById_fkey"; - --- DropForeignKey -ALTER TABLE - "BeerPost" DROP CONSTRAINT "BeerPost_typeId_fkey"; - --- DropForeignKey -ALTER TABLE - "BeerType" DROP CONSTRAINT "BeerType_postedById_fkey"; - --- DropForeignKey -ALTER TABLE - "BreweryComment" DROP CONSTRAINT "BreweryComment_postedById_fkey"; - --- DropForeignKey -ALTER TABLE - "BreweryPost" DROP CONSTRAINT "BreweryPost_postedById_fkey"; - --- CreateTable -CREATE TABLE "BeerImage" ( - "id" TEXT NOT NULL, - "beerPostId" TEXT NOT NULL, - "url" TEXT NOT NULL, - "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMPTZ(3), - CONSTRAINT "BeerImage_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "BreweryImage" ( - "id" TEXT NOT NULL, - "breweryPostId" TEXT NOT NULL, - "url" TEXT NOT NULL, - "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMPTZ(3), - CONSTRAINT "BreweryImage_pkey" PRIMARY KEY ("id") -); - --- AddForeignKey -ALTER TABLE - "BeerPost" -ADD - CONSTRAINT "BeerPost_postedById_fkey" FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE - "BeerPost" -ADD - CONSTRAINT "BeerPost_breweryId_fkey" FOREIGN KEY ("breweryId") REFERENCES "BreweryPost"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE - "BeerPost" -ADD - CONSTRAINT "BeerPost_typeId_fkey" FOREIGN KEY ("typeId") REFERENCES "BeerType"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE - "BeerComment" -ADD - CONSTRAINT "BeerComment_beerPostId_fkey" FOREIGN KEY ("beerPostId") REFERENCES "BeerPost"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE - "BeerComment" -ADD - CONSTRAINT "BeerComment_postedById_fkey" FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE - "BeerType" -ADD - CONSTRAINT "BeerType_postedById_fkey" FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE - "BreweryPost" -ADD - CONSTRAINT "BreweryPost_postedById_fkey" FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE - "BreweryComment" -ADD - CONSTRAINT "BreweryComment_postedById_fkey" FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE - "BeerImage" -ADD - CONSTRAINT "BeerImage_beerPostId_fkey" FOREIGN KEY ("beerPostId") REFERENCES "BeerPost"("id") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE - "BreweryImage" -ADD - CONSTRAINT "BreweryImage_breweryPostId_fkey" FOREIGN KEY ("breweryPostId") REFERENCES "BreweryPost"("id") ON DELETE RESTRICT ON UPDATE CASCADE; \ No newline at end of file diff --git a/prisma/migrations/20230123044455_/migration.sql b/prisma/migrations/20230123044455_/migration.sql deleted file mode 100644 index c58b733..0000000 --- a/prisma/migrations/20230123044455_/migration.sql +++ /dev/null @@ -1,29 +0,0 @@ --- DropForeignKey -ALTER TABLE - "BeerImage" DROP CONSTRAINT "BeerImage_beerPostId_fkey"; - --- DropForeignKey -ALTER TABLE - "BreweryComment" DROP CONSTRAINT "BreweryComment_breweryPostId_fkey"; - --- DropForeignKey -ALTER TABLE - "BreweryImage" DROP CONSTRAINT "BreweryImage_breweryPostId_fkey"; - --- AddForeignKey -ALTER TABLE - "BreweryComment" -ADD - CONSTRAINT "BreweryComment_breweryPostId_fkey" FOREIGN KEY ("breweryPostId") REFERENCES "BreweryPost"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE - "BeerImage" -ADD - CONSTRAINT "BeerImage_beerPostId_fkey" FOREIGN KEY ("beerPostId") REFERENCES "BeerPost"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE - "BreweryImage" -ADD - CONSTRAINT "BreweryImage_breweryPostId_fkey" FOREIGN KEY ("breweryPostId") REFERENCES "BreweryPost"("id") ON DELETE CASCADE ON UPDATE CASCADE; \ No newline at end of file diff --git a/prisma/migrations/20230127095307_/migration.sql b/prisma/migrations/20230127095307_/migration.sql deleted file mode 100644 index 268afa9..0000000 --- a/prisma/migrations/20230127095307_/migration.sql +++ /dev/null @@ -1,12 +0,0 @@ -/* - Warnings: - - - Added the required column `alt` to the `BeerImage` table without a default value. This is not possible if the table is not empty. - - Added the required column `alt` to the `BreweryImage` table without a default value. This is not possible if the table is not empty. - -*/ --- AlterTable -ALTER TABLE "BeerImage" ADD COLUMN "alt" TEXT NOT NULL; - --- AlterTable -ALTER TABLE "BreweryImage" ADD COLUMN "alt" TEXT NOT NULL; diff --git a/prisma/migrations/20230129153944_/migration.sql b/prisma/migrations/20230129153944_/migration.sql deleted file mode 100644 index 2415c4b..0000000 --- a/prisma/migrations/20230129153944_/migration.sql +++ /dev/null @@ -1,12 +0,0 @@ -/* - Warnings: - - - Added the required column `rating` to the `BeerComment` table without a default value. This is not possible if the table is not empty. - - Added the required column `rating` to the `BreweryComment` table without a default value. This is not possible if the table is not empty. - -*/ --- AlterTable -ALTER TABLE "BeerComment" ADD COLUMN "rating" INTEGER NOT NULL; - --- AlterTable -ALTER TABLE "BreweryComment" ADD COLUMN "rating" INTEGER NOT NULL; diff --git a/prisma/migrations/20230203013640_/migration.sql b/prisma/migrations/20230203013640_/migration.sql deleted file mode 100644 index 3639238..0000000 --- a/prisma/migrations/20230203013640_/migration.sql +++ /dev/null @@ -1,8 +0,0 @@ -/* - Warnings: - - - Added the required column `hash` to the `User` table without a default value. This is not possible if the table is not empty. - -*/ --- AlterTable -ALTER TABLE "User" ADD COLUMN "hash" TEXT NOT NULL; diff --git a/prisma/migrations/20230206001052_/migration.sql b/prisma/migrations/20230206001052_/migration.sql deleted file mode 100644 index 74bc6d3..0000000 --- a/prisma/migrations/20230206001052_/migration.sql +++ /dev/null @@ -1,12 +0,0 @@ -/* - Warnings: - - - A unique constraint covering the columns `[username]` on the table `User` will be added. If there are existing duplicate values, this will fail. - - A unique constraint covering the columns `[email]` on the table `User` will be added. If there are existing duplicate values, this will fail. - -*/ --- CreateIndex -CREATE UNIQUE INDEX "User_username_key" ON "User"("username"); - --- CreateIndex -CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); diff --git a/prisma/migrations/20230209085224_/migration.sql b/prisma/migrations/20230209085224_/migration.sql deleted file mode 100644 index 35d2edd..0000000 --- a/prisma/migrations/20230209085224_/migration.sql +++ /dev/null @@ -1,16 +0,0 @@ --- CreateTable -CREATE TABLE "BeerPostLike" ( - "id" TEXT NOT NULL, - "beerPostId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMPTZ(3), - - CONSTRAINT "BeerPostLike_pkey" PRIMARY KEY ("id") -); - --- AddForeignKey -ALTER TABLE "BeerPostLike" ADD CONSTRAINT "BeerPostLike_beerPostId_fkey" FOREIGN KEY ("beerPostId") REFERENCES "BeerPost"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "BeerPostLike" ADD CONSTRAINT "BeerPostLike_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/migrations/20230211021836_/migration.sql b/prisma/migrations/20230211021836_/migration.sql deleted file mode 100644 index 68da21c..0000000 --- a/prisma/migrations/20230211021836_/migration.sql +++ /dev/null @@ -1,30 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `url` on the `BeerImage` table. All the data in the column will be lost. - - You are about to drop the column `url` on the `BreweryImage` table. All the data in the column will be lost. - - Added the required column `caption` to the `BeerImage` table without a default value. This is not possible if the table is not empty. - - Added the required column `path` to the `BeerImage` table without a default value. This is not possible if the table is not empty. - - Added the required column `postedById` to the `BeerImage` table without a default value. This is not possible if the table is not empty. - - Added the required column `caption` to the `BreweryImage` table without a default value. This is not possible if the table is not empty. - - Added the required column `path` to the `BreweryImage` table without a default value. This is not possible if the table is not empty. - - Added the required column `postedById` to the `BreweryImage` table without a default value. This is not possible if the table is not empty. - -*/ --- AlterTable -ALTER TABLE "BeerImage" DROP COLUMN "url", -ADD COLUMN "caption" TEXT NOT NULL, -ADD COLUMN "path" TEXT NOT NULL, -ADD COLUMN "postedById" TEXT NOT NULL; - --- AlterTable -ALTER TABLE "BreweryImage" DROP COLUMN "url", -ADD COLUMN "caption" TEXT NOT NULL, -ADD COLUMN "path" TEXT NOT NULL, -ADD COLUMN "postedById" TEXT NOT NULL; - --- AddForeignKey -ALTER TABLE "BeerImage" ADD CONSTRAINT "BeerImage_postedById_fkey" FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "BreweryImage" ADD CONSTRAINT "BreweryImage_postedById_fkey" FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/migrations/20230213214022_/migration.sql b/prisma/migrations/20230213214022_/migration.sql deleted file mode 100644 index 93392cf..0000000 --- a/prisma/migrations/20230213214022_/migration.sql +++ /dev/null @@ -1,16 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `userId` on the `BeerPostLike` table. All the data in the column will be lost. - - Added the required column `likedById` to the `BeerPostLike` table without a default value. This is not possible if the table is not empty. - -*/ --- DropForeignKey -ALTER TABLE "BeerPostLike" DROP CONSTRAINT "BeerPostLike_userId_fkey"; - --- AlterTable -ALTER TABLE "BeerPostLike" DROP COLUMN "userId", -ADD COLUMN "likedById" TEXT NOT NULL; - --- AddForeignKey -ALTER TABLE "BeerPostLike" ADD CONSTRAINT "BeerPostLike_likedById_fkey" FOREIGN KEY ("likedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/migrations/20230304185749_/migration.sql b/prisma/migrations/20230304185749_/migration.sql deleted file mode 100644 index 91dff5d..0000000 --- a/prisma/migrations/20230304185749_/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- AlterTable -ALTER TABLE "User" ADD COLUMN "isAccountVerified" BOOLEAN NOT NULL DEFAULT false; diff --git a/prisma/migrations/20230406013055_/migration.sql b/prisma/migrations/20230406013055_/migration.sql new file mode 100644 index 0000000..c41b620 --- /dev/null +++ b/prisma/migrations/20230406013055_/migration.sql @@ -0,0 +1,171 @@ +-- CreateTable +CREATE TABLE "User" ( + "id" STRING NOT NULL, + "username" STRING NOT NULL, + "firstName" STRING NOT NULL, + "lastName" STRING NOT NULL, + "hash" STRING NOT NULL, + "email" STRING NOT NULL, + "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMPTZ(3), + "isAccountVerified" BOOL NOT NULL DEFAULT false, + "dateOfBirth" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "User_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "BeerPost" ( + "id" STRING NOT NULL, + "name" STRING NOT NULL, + "ibu" FLOAT8 NOT NULL, + "abv" FLOAT8 NOT NULL, + "description" STRING NOT NULL, + "postedById" STRING NOT NULL, + "breweryId" STRING NOT NULL, + "typeId" STRING NOT NULL, + "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMPTZ(3), + + CONSTRAINT "BeerPost_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "BeerPostLike" ( + "id" STRING NOT NULL, + "beerPostId" STRING NOT NULL, + "likedById" STRING NOT NULL, + "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMPTZ(3), + + CONSTRAINT "BeerPostLike_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "BeerComment" ( + "id" STRING NOT NULL, + "rating" INT4 NOT NULL, + "beerPostId" STRING NOT NULL, + "postedById" STRING NOT NULL, + "content" STRING NOT NULL, + "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMPTZ(3), + + CONSTRAINT "BeerComment_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "BeerType" ( + "id" STRING NOT NULL, + "name" STRING NOT NULL, + "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMPTZ(3), + "postedById" STRING NOT NULL, + + CONSTRAINT "BeerType_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "BreweryPost" ( + "id" STRING NOT NULL, + "name" STRING NOT NULL, + "location" STRING NOT NULL, + "description" STRING NOT NULL, + "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMPTZ(3), + "postedById" STRING NOT NULL, + + CONSTRAINT "BreweryPost_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "BreweryComment" ( + "id" STRING NOT NULL, + "rating" INT4 NOT NULL, + "breweryPostId" STRING NOT NULL, + "postedById" STRING NOT NULL, + "content" STRING NOT NULL, + "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMPTZ(3), + + CONSTRAINT "BreweryComment_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "BeerImage" ( + "id" STRING NOT NULL, + "beerPostId" STRING NOT NULL, + "path" STRING NOT NULL, + "alt" STRING NOT NULL, + "caption" STRING NOT NULL, + "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMPTZ(3), + "postedById" STRING NOT NULL, + + CONSTRAINT "BeerImage_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "BreweryImage" ( + "id" STRING NOT NULL, + "breweryPostId" STRING NOT NULL, + "path" STRING NOT NULL, + "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMPTZ(3), + "caption" STRING NOT NULL, + "alt" STRING NOT NULL, + "postedById" STRING NOT NULL, + + CONSTRAINT "BreweryImage_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "User_username_key" ON "User"("username"); + +-- CreateIndex +CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); + +-- AddForeignKey +ALTER TABLE "BeerPost" ADD CONSTRAINT "BeerPost_postedById_fkey" FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "BeerPost" ADD CONSTRAINT "BeerPost_breweryId_fkey" FOREIGN KEY ("breweryId") REFERENCES "BreweryPost"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "BeerPost" ADD CONSTRAINT "BeerPost_typeId_fkey" FOREIGN KEY ("typeId") REFERENCES "BeerType"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "BeerPostLike" ADD CONSTRAINT "BeerPostLike_beerPostId_fkey" FOREIGN KEY ("beerPostId") REFERENCES "BeerPost"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "BeerPostLike" ADD CONSTRAINT "BeerPostLike_likedById_fkey" FOREIGN KEY ("likedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "BeerComment" ADD CONSTRAINT "BeerComment_beerPostId_fkey" FOREIGN KEY ("beerPostId") REFERENCES "BeerPost"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "BeerComment" ADD CONSTRAINT "BeerComment_postedById_fkey" FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "BeerType" ADD CONSTRAINT "BeerType_postedById_fkey" FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "BreweryPost" ADD CONSTRAINT "BreweryPost_postedById_fkey" FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "BreweryComment" ADD CONSTRAINT "BreweryComment_breweryPostId_fkey" FOREIGN KEY ("breweryPostId") REFERENCES "BreweryPost"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "BreweryComment" ADD CONSTRAINT "BreweryComment_postedById_fkey" FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "BeerImage" ADD CONSTRAINT "BeerImage_beerPostId_fkey" FOREIGN KEY ("beerPostId") REFERENCES "BeerPost"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "BeerImage" ADD CONSTRAINT "BeerImage_postedById_fkey" FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "BreweryImage" ADD CONSTRAINT "BreweryImage_breweryPostId_fkey" FOREIGN KEY ("breweryPostId") REFERENCES "BreweryPost"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "BreweryImage" ADD CONSTRAINT "BreweryImage_postedById_fkey" FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml index fbffa92..7106c8a 100644 --- a/prisma/migrations/migration_lock.toml +++ b/prisma/migrations/migration_lock.toml @@ -1,3 +1,3 @@ # Please do not edit this file manually # It should be added in your version-control system (i.e. Git) -provider = "postgresql" \ No newline at end of file +provider = "cockroachdb" \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma index eb42470..37eb553 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -6,7 +6,7 @@ generator client { } datasource db { - provider = "postgresql" + provider = "cockroachdb" url = env("DATABASE_URL") }