Skip to content

Commit

Permalink
fix: 🐛 fix migration file
Browse files Browse the repository at this point in the history
  • Loading branch information
yeukfei02 committed Apr 20, 2022
1 parent 2e7bea5 commit dae1e9f
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 115 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,41 @@
-- DropForeignKey
ALTER TABLE "location" DROP CONSTRAINT "location_users_id_fkey";
-- CreateEnum
CREATE TYPE "Title" AS ENUM ('mr', 'ms', 'mrs', 'miss', 'dr');

-- AlterTable
ALTER TABLE "location" ALTER COLUMN "users_id" DROP NOT NULL;
-- CreateEnum
CREATE TYPE "Gender" AS ENUM ('male', 'female', 'other');

-- CreateTable
CREATE TABLE "users" (
"id" UUID NOT NULL,
"title" "Title" NOT NULL,
"first_name" VARCHAR(50),
"last_name" VARCHAR(50),
"gender" "Gender" NOT NULL,
"email" TEXT,
"date_of_birth" TIMESTAMP(3),
"register_date" TIMESTAMP(3),
"phone" TEXT,
"picture" TEXT,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "users_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "location" (
"id" UUID NOT NULL,
"street" VARCHAR(100) NOT NULL,
"city" TEXT NOT NULL,
"state" TEXT NOT NULL,
"country" TEXT NOT NULL,
"timezone" TEXT NOT NULL,
"users_id" UUID,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "location_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "post" (
Expand Down Expand Up @@ -43,7 +76,64 @@ CREATE TABLE "comment" (
);

-- CreateIndex
CREATE INDEX "index_post_on_text" ON "post"("text");
CREATE INDEX "index_users_on_created_at" ON "users"("created_at");

-- CreateIndex
CREATE INDEX "index_users_on_date_of_birth" ON "users"("date_of_birth");

-- CreateIndex
CREATE INDEX "index_users_on_email" ON "users"("email");

-- CreateIndex
CREATE INDEX "index_users_on_first_name" ON "users"("first_name");

-- CreateIndex
CREATE INDEX "index_users_on_gender" ON "users"("gender");

-- CreateIndex
CREATE INDEX "index_users_on_last_name" ON "users"("last_name");

-- CreateIndex
CREATE INDEX "index_users_on_phone" ON "users"("phone");

-- CreateIndex
CREATE INDEX "index_users_on_picture" ON "users"("picture");

-- CreateIndex
CREATE INDEX "index_users_on_register_date" ON "users"("register_date");

-- CreateIndex
CREATE INDEX "index_users_on_title" ON "users"("title");

-- CreateIndex
CREATE INDEX "index_users_on_updated_at" ON "users"("updated_at");

-- CreateIndex
CREATE INDEX "index_location_on_city" ON "location"("city");

-- CreateIndex
CREATE INDEX "index_location_on_country" ON "location"("country");

-- CreateIndex
CREATE INDEX "index_location_on_created_at" ON "location"("created_at");

-- CreateIndex
CREATE INDEX "index_location_on_state" ON "location"("state");

-- CreateIndex
CREATE INDEX "index_location_on_street" ON "location"("street");

-- CreateIndex
CREATE INDEX "index_location_on_timezone" ON "location"("timezone");

-- CreateIndex
CREATE INDEX "index_location_on_updated_at" ON "location"("updated_at");

-- CreateIndex
CREATE INDEX "index_location_on_users_id" ON "location"("users_id");

-- CreateIndex
CREATE INDEX "index_post_on_created_at" ON "post"("created_at");

-- CreateIndex
CREATE INDEX "index_post_on_image" ON "post"("image");
Expand All @@ -55,13 +145,13 @@ CREATE INDEX "index_post_on_likes" ON "post"("likes");
CREATE INDEX "index_post_on_publish_date" ON "post"("publish_date");

-- CreateIndex
CREATE INDEX "index_post_on_users_id" ON "post"("users_id");
CREATE INDEX "index_post_on_text" ON "post"("text");

-- CreateIndex
CREATE INDEX "index_post_on_created_at" ON "post"("created_at");
CREATE INDEX "index_post_on_updated_at" ON "post"("updated_at");

-- CreateIndex
CREATE INDEX "index_post_on_updated_at" ON "post"("updated_at");
CREATE INDEX "index_post_on_users_id" ON "post"("users_id");

-- CreateIndex
CREATE INDEX "index_tag_on_created_at" ON "tag"("created_at");
Expand All @@ -78,17 +168,20 @@ CREATE INDEX "index_tag_on_updated_at" ON "tag"("updated_at");
-- CreateIndex
CREATE INDEX "index_comment_on_created_at" ON "comment"("created_at");

-- CreateIndex
CREATE INDEX "index_comment_on_message" ON "comment"("message");

-- CreateIndex
CREATE INDEX "index_comment_on_post_id" ON "comment"("post_id");

-- CreateIndex
CREATE INDEX "index_comment_on_users_id" ON "comment"("users_id");
CREATE INDEX "index_comment_on_publish_date" ON "comment"("publish_date");

-- CreateIndex
CREATE INDEX "index_comment_on_updated_at" ON "comment"("updated_at");

-- CreateIndex
CREATE INDEX "index_location_on_users_id" ON "location"("users_id");
CREATE INDEX "index_comment_on_users_id" ON "comment"("users_id");

-- AddForeignKey
ALTER TABLE "location" ADD CONSTRAINT "location_users_id_fkey" FOREIGN KEY ("users_id") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
Expand Down

0 comments on commit dae1e9f

Please sign in to comment.