diff --git a/prisma/migrations/20260213040203_update_user_preference_table/migration.sql b/prisma/migrations/20260213040203_update_user_preference_table/migration.sql new file mode 100644 index 0000000..e5b37e1 --- /dev/null +++ b/prisma/migrations/20260213040203_update_user_preference_table/migration.sql @@ -0,0 +1,38 @@ +/* + Warnings: + + - You are about to drop the column `role` on the `User` table. All the data in the column will be lost. + +*/ +-- CreateEnum +CREATE TYPE "OS" AS ENUM ('WINDOWS', 'MACOS', 'LINUX', 'CHROME_OS', 'OTHER'); + +-- CreateEnum +CREATE TYPE "Brand" AS ENUM ('APPLE', 'ASUS', 'ACER', 'LENOVO', 'HP', 'DELL', 'MSI', 'AXIOO', 'ADVAN', 'ZYREX', 'OTHER'); + +-- AlterTable +ALTER TABLE "User" DROP COLUMN "role", +ADD COLUMN "bio" TEXT, +ADD COLUMN "birthDate" TIMESTAMP(3), +ADD COLUMN "location" TEXT; + +-- CreateTable +CREATE TABLE "UserPreference" ( + "id" SERIAL NOT NULL, + "profession" TEXT, + "preferredOS" "OS", + "preferedBrand" "Brand", + "budgetMin" INTEGER, + "budgetMax" INTEGER, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "userId" INTEGER NOT NULL, + + CONSTRAINT "UserPreference_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "UserPreference_userId_key" ON "UserPreference"("userId"); + +-- AddForeignKey +ALTER TABLE "UserPreference" ADD CONSTRAINT "UserPreference_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index ed8361e..fb29ee8 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -6,7 +6,6 @@ datasource db { provider = "postgresql" } -// --- ENUMS --- enum UserGender { male female @@ -24,6 +23,28 @@ enum Sentiment { NEUTRAL } +enum OS { + WINDOWS + MACOS + LINUX + CHROME_OS + OTHER +} + +enum Brand { + APPLE + ASUS + ACER + LENOVO + HP + DELL + MSI + AXIOO + ADVAN + ZYREX + OTHER +} + model Account { id Int @id @default(autoincrement()) userId Int @@ -64,87 +85,105 @@ model User { email String? @unique emailVerified DateTime? image String? - gender UserGender? password String? - role Role @default(USER) - - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + bio String? @db.Text + location String? + birthDate DateTime? + gender UserGender? - accounts Account[] - sessions Session[] - - analyses Analysis[] -} - -model Product { - id Int @id @default(autoincrement()) - name String - brand String? - url String @unique - image String? - createdAt DateTime @default(now()) updatedAt DateTime @updatedAt - reviews Review[] - analyses Analysis[] + accounts Account[] + sessions Session[] + analyses Analysis[] + + preference UserPreference? +} + +model UserPreference { + id Int @id @default(autoincrement()) + profession String? + preferredOS OS? + preferedBrand Brand? + budgetMin Int? + budgetMax Int? + + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + userId Int @unique + user User @relation(fields: [userId], references: [id], onDelete: Cascade) +} + +model Product { + id Int @id @default(autoincrement()) + name String + brand String? + url String @unique + image String? + + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + reviews Review[] + analyses Analysis[] } model Review { id Int @id @default(autoincrement()) - content String - sentiment Sentiment - confidenceScore Float - keywords String[] - - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + content String + sentiment Sentiment + confidenceScore Float + keywords String[] - productId Int - product Product @relation(fields: [productId], references: [id], onDelete: Cascade) - - modelId Int? - model Model? @relation(fields: [modelId], references: [id]) -} - -model Analysis { - id Int @id @default(autoincrement()) - - targetProfession String - - generalSentiment Float - compatibilityScore Float - verdict String - - topKeywords String[] - - createdAt DateTime @default(now()) - - userId Int - user User @relation(fields: [userId], references: [id], onDelete: Cascade) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt productId Int product Product @relation(fields: [productId], references: [id], onDelete: Cascade) - modelId Int - model Model @relation(fields: [modelId], references: [id]) + modelId Int? + model Model? @relation(fields: [modelId], references: [id]) +} + +model Analysis { + id Int @id @default(autoincrement()) + + targetProfession String + + generalSentiment Float + compatibilityScore Float + verdict String + + topKeywords String[] + + createdAt DateTime @default(now()) + + userId Int + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + productId Int + product Product @relation(fields: [productId], references: [id], onDelete: Cascade) + + modelId Int + model Model @relation(fields: [modelId], references: [id]) } model Model { - id Int @id @default(autoincrement()) - modelName String + id Int @id @default(autoincrement()) + modelName String description String? - version String? - - accuracy Float - macroF1 Float - f1Negative Float - f1Neutral Float - - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + version String? - analyses Analysis[] - reviews Review[] -} \ No newline at end of file + accuracy Float + macroF1 Float + f1Negative Float + f1Neutral Float + + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + analyses Analysis[] + reviews Review[] +} diff --git a/src/app/profile/lib/action.ts b/src/app/profile/lib/action.ts index 900019a..89a01aa 100644 --- a/src/app/profile/lib/action.ts +++ b/src/app/profile/lib/action.ts @@ -12,7 +12,6 @@ export const getAnotherUserData = async () => { where: { email: session.user.email }, select: { gender: true, - productReference: true, }, });