Created
September 1, 2022 21:16
-
-
Save Tosinkoa/416f6d91bbca47c89994b3ddcc5baf8f to your computer and use it in GitHub Desktop.
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
``` | |
-- CreateTable | |
CREATE TABLE "session" ( | |
"sid" VARCHAR NOT NULL, | |
"sess" JSON NOT NULL, | |
"expire" TIMESTAMP() NOT NULL, | |
CONSTRAINT "session_pkey" PRIMARY KEY ("sid") | |
); | |
-- CreateTable | |
CREATE TABLE "slot" ( | |
"id" SERIAL NOT NULL, | |
"user_id" INTEGER NOT NULL, | |
"slot_key" VARCHAR(999)[], | |
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
"updated_at" TIMESTAMP(3) NOT NULL, | |
"week_of_year" INTEGER NOT NULL, | |
"weekly_amount_spent" INTEGER NOT NULL, | |
"weekly_slot_own" INTEGER NOT NULL, | |
"year" INTEGER NOT NULL, | |
CONSTRAINT "slot_pkey" PRIMARY KEY ("id") | |
); | |
-- CreateTable | |
CREATE TABLE "users" ( | |
"id" SERIAL NOT NULL, | |
"first_name" VARCHAR(255) NOT NULL, | |
"last_name" VARCHAR(255) NOT NULL, | |
"email" CITEXT NOT NULL, | |
"phone_number" VARCHAR(255), | |
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
"updated_at" TIMESTAMP(3) NOT NULL, | |
"password" VARCHAR(255) NOT NULL, | |
"profile_image" TEXT NOT NULL, | |
"profile_image_id" TEXT NOT NULL, | |
"verified" BOOLEAN NOT NULL DEFAULT false, | |
"username" CITEXT NOT NULL, | |
"google_user" BOOLEAN NOT NULL DEFAULT false, | |
CONSTRAINT "users_pkey" PRIMARY KEY ("id") | |
); | |
-- CreateTable | |
CREATE TABLE "verifyToken" ( | |
"id" SERIAL NOT NULL, | |
"token" TEXT NOT NULL, | |
"user_id" INTEGER NOT NULL, | |
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
"updated_at" TIMESTAMP(3) NOT NULL, | |
CONSTRAINT "verifyToken_pkey" PRIMARY KEY ("id") | |
); | |
-- CreateTable | |
CREATE TABLE "winner" ( | |
"id" SERIAL NOT NULL, | |
"user_id" INTEGER NOT NULL, | |
"profile_image" TEXT NOT NULL, | |
"profile_image_id" TEXT NOT NULL, | |
"winner_first_name" VARCHAR(255) NOT NULL, | |
"winner_last_name" VARCHAR(255) NOT NULL, | |
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
"updated_at" TIMESTAMP(3) NOT NULL, | |
"winner_username" VARCHAR(255) NOT NULL, | |
"amount_won" INTEGER NOT NULL, | |
CONSTRAINT "winner_pkey" PRIMARY KEY ("id") | |
); | |
-- CreateTable | |
CREATE TABLE "winnersReview" ( | |
"id" SERIAL NOT NULL, | |
"review_title" TEXT NOT NULL, | |
"review_body" TEXT NOT NULL, | |
"winner_id" INTEGER NOT NULL, | |
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
"updated_at" TIMESTAMP(3) NOT NULL, | |
"user_id" INTEGER NOT NULL, | |
CONSTRAINT "winnersReview_pkey" PRIMARY KEY ("id") | |
); | |
-- CreateTable | |
CREATE TABLE "winnersReviewImages" ( | |
"id" SERIAL NOT NULL, | |
"review_image" TEXT[], | |
"review_image_id" TEXT[], | |
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
"updated_at" TIMESTAMP(3) NOT NULL, | |
"winner_review_id" INTEGER NOT NULL, | |
CONSTRAINT "winnersReviewImages_pkey" PRIMARY KEY ("id") | |
); | |
-- CreateIndex | |
CREATE INDEX "IDX_session_expire" ON "session"("expire"); | |
-- CreateIndex | |
CREATE UNIQUE INDEX "slot_id_key" ON "slot"("id"); | |
-- CreateIndex | |
CREATE UNIQUE INDEX "slot_slot_key_key" ON "slot"("slot_key"); | |
-- CreateIndex | |
CREATE UNIQUE INDEX "users_id_key" ON "users"("id"); | |
-- CreateIndex | |
CREATE UNIQUE INDEX "users_email_key" ON "users"("email"); | |
-- CreateIndex | |
CREATE UNIQUE INDEX "users_phone_number_key" ON "users"("phone_number"); | |
-- CreateIndex | |
CREATE UNIQUE INDEX "users_username_key" ON "users"("username"); | |
-- CreateIndex | |
CREATE UNIQUE INDEX "verifyToken_id_key" ON "verifyToken"("id"); | |
-- CreateIndex | |
CREATE UNIQUE INDEX "verifyToken_token_key" ON "verifyToken"("token"); | |
-- CreateIndex | |
CREATE UNIQUE INDEX "verifyToken_user_id_key" ON "verifyToken"("user_id"); | |
-- CreateIndex | |
CREATE UNIQUE INDEX "winner_id_key" ON "winner"("id"); | |
-- CreateIndex | |
CREATE UNIQUE INDEX "winnersReview_id_key" ON "winnersReview"("id"); | |
-- CreateIndex | |
CREATE UNIQUE INDEX "winnersReview_winner_id_key" ON "winnersReview"("winner_id"); | |
-- CreateIndex | |
CREATE UNIQUE INDEX "winnersReviewImages_id_key" ON "winnersReviewImages"("id"); | |
-- CreateIndex | |
CREATE UNIQUE INDEX "winnersReviewImages_winner_review_id_key" ON "winnersReviewImages"("winner_review_id"); | |
-- AddForeignKey | |
ALTER TABLE "slot" ADD CONSTRAINT "slot_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE; | |
-- AddForeignKey | |
ALTER TABLE "verifyToken" ADD CONSTRAINT "verifyToken_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE; | |
-- AddForeignKey | |
ALTER TABLE "winner" ADD CONSTRAINT "winner_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE; | |
-- AddForeignKey | |
ALTER TABLE "winnersReview" ADD CONSTRAINT "winnersReview_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE; | |
-- AddForeignKey | |
ALTER TABLE "winnersReview" ADD CONSTRAINT "winnersReview_winner_id_fkey" FOREIGN KEY ("winner_id") REFERENCES "winner"("id") ON DELETE CASCADE ON UPDATE CASCADE; | |
-- AddForeignKey | |
ALTER TABLE "winnersReviewImages" ADD CONSTRAINT "winnersReviewImages_winner_review_id_fkey" FOREIGN KEY ("winner_review_id") REFERENCES "winnersReview"("id") ON DELETE CASCADE ON UPDATE CASCADE; | |
``` |
DanielFGray
commented
Sep 1, 2022
•
Thank you so much for helping me out, I value the insights and guidance you provide, thanks again. @DanielFGray and anyone else who help me out with this
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment