mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
Switch database to cockroach db and remove height on comment card
This commit is contained in:
@@ -69,7 +69,7 @@ const CommentCardBody: React.FC<{
|
||||
const timeDistance = useTimeDistance(new Date(comment.createdAt));
|
||||
|
||||
return (
|
||||
<div className="card-body h-64 animate-in fade-in-10">
|
||||
<div className="card-body animate-in fade-in-10">
|
||||
<div className="flex flex-col justify-between sm:flex-row">
|
||||
<div>
|
||||
<h3 className="font-semibold sm:text-2xl">
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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");
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "User" ADD COLUMN "isAccountVerified" BOOLEAN NOT NULL DEFAULT false;
|
||||
171
prisma/migrations/20230406013055_/migration.sql
Normal file
171
prisma/migrations/20230406013055_/migration.sql
Normal file
@@ -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;
|
||||
@@ -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"
|
||||
provider = "cockroachdb"
|
||||
@@ -6,7 +6,7 @@ generator client {
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
provider = "cockroachdb"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user