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/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[]; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 87539ef..81a5845 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) @@ -49,16 +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 - - @@index([categories], type: Gin) - @@index([subcategories], type: Gin) }