-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
193 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
-- CreateEnum | ||
CREATE TYPE "NotificationType" AS ENUM ('ZAP_NOW', 'FRIEND_REQUEST', 'NEW_DAILY_ZAP', 'NEW_REACTION', 'NEW_COMMENT', 'TAGGED'); | ||
|
||
-- CreateEnum | ||
CREATE TYPE "ReactionType" AS ENUM ('THUMBS_UP', 'GRINNING_FACE_WITH_BIG_EYES', 'ASTONISHED_FACE', 'FACE_WITH_TEARS_OF_JOY', 'SMILING_FACE_WITH_HEART_EYES', 'HIGH_VOLTAGE'); | ||
|
||
-- CreateEnum | ||
CREATE TYPE "Region" AS ENUM ('EU', 'US', 'WA', 'EA'); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Comment" ( | ||
"id" TEXT NOT NULL, | ||
"authorId" TEXT NOT NULL, | ||
"zapId" TEXT NOT NULL, | ||
"content" TEXT NOT NULL, | ||
|
||
CONSTRAINT "Comment_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "FriendRequest" ( | ||
"id" TEXT NOT NULL, | ||
"senderId" TEXT NOT NULL, | ||
"receiverId" TEXT NOT NULL, | ||
|
||
CONSTRAINT "FriendRequest_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Friendship" ( | ||
"id" TEXT NOT NULL, | ||
"senderId" TEXT NOT NULL, | ||
"receiverId" TEXT NOT NULL, | ||
|
||
CONSTRAINT "Friendship_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Invite" ( | ||
"id" TEXT NOT NULL, | ||
"code" TEXT NOT NULL, | ||
"userId" TEXT, | ||
|
||
CONSTRAINT "Invite_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Moment" ( | ||
"id" TEXT NOT NULL, | ||
"date" TIMESTAMP(3) NOT NULL, | ||
"timestampEU" TIMESTAMP(3) NOT NULL, | ||
"timestampUS" TIMESTAMP(3) NOT NULL, | ||
"timestampWA" TIMESTAMP(3) NOT NULL, | ||
"timestampEA" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "Moment_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Notification" ( | ||
"id" TEXT NOT NULL, | ||
"userId" TEXT NOT NULL, | ||
"type" "NotificationType" NOT NULL, | ||
"targetId" TEXT, | ||
"title" TEXT NOT NULL, | ||
"content" TEXT NOT NULL, | ||
|
||
CONSTRAINT "Notification_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Reaction" ( | ||
"id" TEXT NOT NULL, | ||
"authorId" TEXT NOT NULL, | ||
"zapId" TEXT NOT NULL, | ||
"type" "ReactionType" NOT NULL, | ||
"imageId" TEXT NOT NULL, | ||
|
||
CONSTRAINT "Reaction_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "ReactionImage" ( | ||
"id" TEXT NOT NULL, | ||
"uploaded" BOOLEAN NOT NULL, | ||
|
||
CONSTRAINT "ReactionImage_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "User" ( | ||
"id" TEXT NOT NULL, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
"handle" TEXT NOT NULL, | ||
"email" TEXT NOT NULL, | ||
"firstName" TEXT NOT NULL, | ||
"lastName" TEXT NOT NULL, | ||
"region" "Region" NOT NULL, | ||
"profilePictureVersion" INTEGER NOT NULL DEFAULT 0, | ||
"otp" TEXT, | ||
"deviceToken" TEXT, | ||
"loginToken" TEXT, | ||
"sessionToken" TEXT, | ||
|
||
CONSTRAINT "User_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Zap" ( | ||
"id" TEXT NOT NULL, | ||
"authorId" TEXT NOT NULL, | ||
"momentId" TEXT NOT NULL, | ||
"repostId" TEXT, | ||
"uploaded" BOOLEAN NOT NULL, | ||
|
||
CONSTRAINT "Zap_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "FriendRequest_senderId_receiverId_key" ON "FriendRequest"("senderId", "receiverId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Friendship_senderId_receiverId_key" ON "Friendship"("senderId", "receiverId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Invite_userId_key" ON "Invite"("userId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Moment_date_key" ON "Moment"("date"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_handle_key" ON "User"("handle"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_deviceToken_key" ON "User"("deviceToken"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_loginToken_key" ON "User"("loginToken"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_sessionToken_key" ON "User"("sessionToken"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Zap_authorId_repostId_key" ON "Zap"("authorId", "repostId"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Comment" ADD CONSTRAINT "Comment_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Comment" ADD CONSTRAINT "Comment_zapId_fkey" FOREIGN KEY ("zapId") REFERENCES "Zap"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "FriendRequest" ADD CONSTRAINT "FriendRequest_senderId_fkey" FOREIGN KEY ("senderId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "FriendRequest" ADD CONSTRAINT "FriendRequest_receiverId_fkey" FOREIGN KEY ("receiverId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Friendship" ADD CONSTRAINT "Friendship_senderId_fkey" FOREIGN KEY ("senderId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Friendship" ADD CONSTRAINT "Friendship_receiverId_fkey" FOREIGN KEY ("receiverId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Invite" ADD CONSTRAINT "Invite_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Notification" ADD CONSTRAINT "Notification_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Reaction" ADD CONSTRAINT "Reaction_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Reaction" ADD CONSTRAINT "Reaction_zapId_fkey" FOREIGN KEY ("zapId") REFERENCES "Zap"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Reaction" ADD CONSTRAINT "Reaction_imageId_fkey" FOREIGN KEY ("imageId") REFERENCES "ReactionImage"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Zap" ADD CONSTRAINT "Zap_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Zap" ADD CONSTRAINT "Zap_momentId_fkey" FOREIGN KEY ("momentId") REFERENCES "Moment"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Zap" ADD CONSTRAINT "Zap_repostId_fkey" FOREIGN KEY ("repostId") REFERENCES "Zap"("id") ON DELETE SET NULL ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "postgresql" |