From 364fe372963d1e3c844974c92850604a8a5eae1b Mon Sep 17 00:00:00 2001 From: max Date: Fri, 26 Jan 2024 11:05:27 -0300 Subject: [PATCH 1/2] Adding the migration to include the project. --- .../20240124155705_user_create/migration.sql | 15 --------- .../migration.sql | 32 +++++++++++++++++++ prisma/schema.prisma | 15 +++++++++ 3 files changed, 47 insertions(+), 15 deletions(-) delete mode 100644 prisma/migrations/20240124155705_user_create/migration.sql create mode 100644 prisma/migrations/20240126134916_orange_db_portfolio/migration.sql diff --git a/prisma/migrations/20240124155705_user_create/migration.sql b/prisma/migrations/20240124155705_user_create/migration.sql deleted file mode 100644 index 76e064a..0000000 --- a/prisma/migrations/20240124155705_user_create/migration.sql +++ /dev/null @@ -1,15 +0,0 @@ --- CreateTable -CREATE TABLE "User" ( - "id" TEXT NOT NULL, - "name" TEXT NOT NULL, - "surname" TEXT NOT NULL, - "email" TEXT NOT NULL, - "password_hash" TEXT NOT NULL, - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "User_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); diff --git a/prisma/migrations/20240126134916_orange_db_portfolio/migration.sql b/prisma/migrations/20240126134916_orange_db_portfolio/migration.sql new file mode 100644 index 0000000..652105a --- /dev/null +++ b/prisma/migrations/20240126134916_orange_db_portfolio/migration.sql @@ -0,0 +1,32 @@ +-- CreateTable +CREATE TABLE "User" ( + "id" TEXT NOT NULL, + "name" TEXT NOT NULL, + "surname" TEXT NOT NULL, + "email" TEXT NOT NULL, + "password_hash" TEXT NOT NULL, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "User_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "AddProject" ( + "id" TEXT NOT NULL, + "title" TEXT NOT NULL, + "tags" TEXT NOT NULL, + "link" TEXT NOT NULL, + "description" TEXT NOT NULL, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMP(3) NOT NULL, + "user_id" TEXT NOT NULL, + + CONSTRAINT "AddProject_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); + +-- AddForeignKey +ALTER TABLE "AddProject" ADD CONSTRAINT "AddProject_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index d515a4c..ff7aaa1 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -15,4 +15,19 @@ model User { password_hash String created_at DateTime @default(now()) updated_at DateTime @updatedAt + + addProjects AddProject[] } + +model AddProject { + id String @id @default(uuid()) + title String + tags String + link String + description String + created_at DateTime @default(now()) + updated_at DateTime @updatedAt + + user User @relation(fields: [user_id], references: [id]) + user_id String +} \ No newline at end of file From dc71cffce0ce45d1e6fcae3774706b6967c483d8 Mon Sep 17 00:00:00 2001 From: max Date: Fri, 26 Jan 2024 12:05:38 -0300 Subject: [PATCH 2/2] Correction of reviews, migration files, and project model name. --- .../20240124155705_user_create/migration.sql | 15 +++++++++ .../migration.sql | 32 ------------------- .../20240126145824_add_project/migration.sql | 16 ++++++++++ prisma/schema.prisma | 5 ++- 4 files changed, 33 insertions(+), 35 deletions(-) create mode 100644 prisma/migrations/20240124155705_user_create/migration.sql delete mode 100644 prisma/migrations/20240126134916_orange_db_portfolio/migration.sql create mode 100644 prisma/migrations/20240126145824_add_project/migration.sql diff --git a/prisma/migrations/20240124155705_user_create/migration.sql b/prisma/migrations/20240124155705_user_create/migration.sql new file mode 100644 index 0000000..76e064a --- /dev/null +++ b/prisma/migrations/20240124155705_user_create/migration.sql @@ -0,0 +1,15 @@ +-- CreateTable +CREATE TABLE "User" ( + "id" TEXT NOT NULL, + "name" TEXT NOT NULL, + "surname" TEXT NOT NULL, + "email" TEXT NOT NULL, + "password_hash" TEXT NOT NULL, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "User_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); diff --git a/prisma/migrations/20240126134916_orange_db_portfolio/migration.sql b/prisma/migrations/20240126134916_orange_db_portfolio/migration.sql deleted file mode 100644 index 652105a..0000000 --- a/prisma/migrations/20240126134916_orange_db_portfolio/migration.sql +++ /dev/null @@ -1,32 +0,0 @@ --- CreateTable -CREATE TABLE "User" ( - "id" TEXT NOT NULL, - "name" TEXT NOT NULL, - "surname" TEXT NOT NULL, - "email" TEXT NOT NULL, - "password_hash" TEXT NOT NULL, - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "User_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "AddProject" ( - "id" TEXT NOT NULL, - "title" TEXT NOT NULL, - "tags" TEXT NOT NULL, - "link" TEXT NOT NULL, - "description" TEXT NOT NULL, - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" TIMESTAMP(3) NOT NULL, - "user_id" TEXT NOT NULL, - - CONSTRAINT "AddProject_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); - --- AddForeignKey -ALTER TABLE "AddProject" ADD CONSTRAINT "AddProject_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20240126145824_add_project/migration.sql b/prisma/migrations/20240126145824_add_project/migration.sql new file mode 100644 index 0000000..313726f --- /dev/null +++ b/prisma/migrations/20240126145824_add_project/migration.sql @@ -0,0 +1,16 @@ +-- CreateTable +CREATE TABLE "Project" ( + "id" TEXT NOT NULL, + "title" TEXT NOT NULL, + "tags" TEXT NOT NULL, + "link" TEXT NOT NULL, + "description" TEXT NOT NULL, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMP(3) NOT NULL, + "user_id" TEXT NOT NULL, + + CONSTRAINT "Project_pkey" PRIMARY KEY ("id") +); + +-- AddForeignKey +ALTER TABLE "Project" ADD CONSTRAINT "Project_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index ff7aaa1..bb2f9fb 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -16,10 +16,9 @@ model User { created_at DateTime @default(now()) updated_at DateTime @updatedAt - addProjects AddProject[] + projects Project[] } - -model AddProject { +model Project { id String @id @default(uuid()) title String tags String