Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions prisma/migrations/20250915081725_add_subpost_model/migration.sql
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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[];
19 changes: 14 additions & 5 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}