From f7ab5be9b17db0bf10b6f76f830057c05f0e9dc6 Mon Sep 17 00:00:00 2001 From: Ginza Hatemi Date: Mon, 15 Sep 2025 02:19:21 -0600 Subject: [PATCH 1/3] feat: Add Subpost model and update Post model to include subposts --- .../20250915081725_add_subpost_model/migration.sql | 13 +++++++++++++ prisma/schema.prisma | 12 +++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 prisma/migrations/20250915081725_add_subpost_model/migration.sql diff --git a/prisma/migrations/20250915081725_add_subpost_model/migration.sql b/prisma/migrations/20250915081725_add_subpost_model/migration.sql new file mode 100644 index 0000000..5eebb35 --- /dev/null +++ b/prisma/migrations/20250915081725_add_subpost_model/migration.sql @@ -0,0 +1,13 @@ +-- CreateTable +CREATE TABLE "public"."Subpost" ( + "id" TEXT NOT NULL, + "content" TEXT NOT NULL, + "postId" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Subpost_pkey" PRIMARY KEY ("id") +); + +-- AddForeignKey +ALTER TABLE "public"."Subpost" ADD CONSTRAINT "Subpost_postId_fkey" FOREIGN KEY ("postId") REFERENCES "public"."Post"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 87539ef..43986c5 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -16,7 +16,7 @@ datasource db { model User { id String @id @default(uuid()) walletAddress String? @unique - email String? @unique + email String? @unique name String? password String? role Role @default(USER) @@ -58,7 +58,17 @@ model Post { subcategories String[] @default([]) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt + subposts Subpost[] @@index([categories], type: Gin) @@index([subcategories], type: Gin) } + +model Subpost { + id String @id @default(uuid()) + content String + postId String + post Post @relation(fields: [postId], references: [id]) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt +} From 58d7c872ee5874437b15c71c55b2fa133256a997 Mon Sep 17 00:00:00 2001 From: Ginza Hatemi Date: Mon, 15 Sep 2025 03:00:17 -0600 Subject: [PATCH 2/3] refactor: Simplify Post and Subpost models by removing redundant fields and restructuring --- prisma/schema.prisma | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 43986c5..81a5845 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -49,26 +49,25 @@ enum Source { } model Post { + id String @id @default(uuid()) + title String + subposts Subpost[] + totalSubposts Int @default(0) + bullishSummary String? + bearishSummary String? + neutralSummary String? +} + +model Subpost { id String @id @default(uuid()) - title String content String sentiment Sentiment source Source categories String[] @default([]) subcategories String[] @default([]) + link String? + postId String + post Post @relation(fields: [postId], references: [id]) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt - subposts Subpost[] - - @@index([categories], type: Gin) - @@index([subcategories], type: Gin) -} - -model Subpost { - id String @id @default(uuid()) - content String - postId String - post Post @relation(fields: [postId], references: [id]) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt } From 162cb0d8e1159c4aeda7da14151b84674763fe8d Mon Sep 17 00:00:00 2001 From: Ginza Hatemi Date: Mon, 15 Sep 2025 03:07:20 -0600 Subject: [PATCH 3/3] feat: Update Post and Subpost models by dropping redundant columns and adding new fields --- .../migration.sql | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 prisma/migrations/20250915090632_update_post_subpost_model/migration.sql diff --git a/prisma/migrations/20250915090632_update_post_subpost_model/migration.sql b/prisma/migrations/20250915090632_update_post_subpost_model/migration.sql new file mode 100644 index 0000000..8a8b750 --- /dev/null +++ b/prisma/migrations/20250915090632_update_post_subpost_model/migration.sql @@ -0,0 +1,39 @@ +/* + Warnings: + + - You are about to drop the column `categories` on the `Post` table. All the data in the column will be lost. + - You are about to drop the column `content` on the `Post` table. All the data in the column will be lost. + - You are about to drop the column `createdAt` on the `Post` table. All the data in the column will be lost. + - You are about to drop the column `sentiment` on the `Post` table. All the data in the column will be lost. + - You are about to drop the column `source` on the `Post` table. All the data in the column will be lost. + - You are about to drop the column `subcategories` on the `Post` table. All the data in the column will be lost. + - You are about to drop the column `updatedAt` on the `Post` table. All the data in the column will be lost. + - Added the required column `sentiment` to the `Subpost` table without a default value. This is not possible if the table is not empty. + - Added the required column `source` to the `Subpost` table without a default value. This is not possible if the table is not empty. + +*/ +-- DropIndex +DROP INDEX "public"."Post_categories_idx"; + +-- DropIndex +DROP INDEX "public"."Post_subcategories_idx"; + +-- AlterTable +ALTER TABLE "public"."Post" DROP COLUMN "categories", +DROP COLUMN "content", +DROP COLUMN "createdAt", +DROP COLUMN "sentiment", +DROP COLUMN "source", +DROP COLUMN "subcategories", +DROP COLUMN "updatedAt", +ADD COLUMN "bearishSummary" TEXT, +ADD COLUMN "bullishSummary" TEXT, +ADD COLUMN "neutralSummary" TEXT, +ADD COLUMN "totalSubposts" INTEGER NOT NULL DEFAULT 0; + +-- AlterTable +ALTER TABLE "public"."Subpost" ADD COLUMN "categories" TEXT[] DEFAULT ARRAY[]::TEXT[], +ADD COLUMN "link" TEXT, +ADD COLUMN "sentiment" "public"."Sentiment" NOT NULL, +ADD COLUMN "source" "public"."Source" NOT NULL, +ADD COLUMN "subcategories" TEXT[] DEFAULT ARRAY[]::TEXT[];