Skip to content

Commit

Permalink
chore: modify prisma schema datatype
Browse files Browse the repository at this point in the history
  • Loading branch information
joannechen1223 committed Mar 6, 2024
1 parent 7306579 commit 99a0760
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CREATE TYPE "Role" AS ENUM ('ADMIN', 'USER');

-- CreateTable
CREATE TABLE "User" (
"id" TEXT NOT NULL,
"id" VARCHAR(64) NOT NULL,
"provider" "Provider" NOT NULL,
"providerId" VARCHAR(128) NOT NULL,
"email" VARCHAR(128) NOT NULL,
Expand All @@ -26,18 +26,18 @@ CREATE TABLE "User" (

-- CreateTable
CREATE TABLE "FollowingRecord" (
"userId" TEXT NOT NULL,
"followerId" TEXT NOT NULL,
"userId" VARCHAR(64) NOT NULL,
"followerId" VARCHAR(64) NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "FollowingRecord_pkey" PRIMARY KEY ("userId","followerId")
);

-- CreateTable
CREATE TABLE "Recommendation" (
"id" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"articleId" TEXT NOT NULL,
"id" VARCHAR(64) NOT NULL,
"userId" VARCHAR(64) NOT NULL,
"articleId" VARCHAR(64) NOT NULL,
"description" TEXT NOT NULL,
"cutoff" TIMESTAMP(3) NOT NULL,
"createAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
Expand All @@ -48,7 +48,7 @@ CREATE TABLE "Recommendation" (

-- CreateTable
CREATE TABLE "Article" (
"id" TEXT NOT NULL,
"id" VARCHAR(64) NOT NULL,
"doi" VARCHAR(32),
"title" VARCHAR(256) NOT NULL,
"author" VARCHAR(256) NOT NULL,
Expand All @@ -66,9 +66,9 @@ CREATE TABLE "Article" (
CREATE TABLE "InviteCode" (
"id" SERIAL NOT NULL,
"code" VARCHAR(64) NOT NULL,
"ownerId" VARCHAR(32) NOT NULL,
"ownerId" VARCHAR(64) NOT NULL,
"issuedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"usedById" VARCHAR(32),
"usedById" VARCHAR(64),
"usedAt" TIMESTAMP(3),

CONSTRAINT "InviteCode_pkey" PRIMARY KEY ("id")
Expand Down
26 changes: 13 additions & 13 deletions apps/recnet-api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ enum Role {
}

model User {
id String @id @default(uuid()) // Primary key, UUID type
id String @id @db.VarChar(64) @default(uuid()) // Primary key, UUID type
provider Provider // Enum type
providerId String @db.VarChar(128)
email String @db.VarChar(128) @unique
Expand All @@ -41,16 +41,16 @@ model User {
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
following FollowingRecord[] @relation("Following")
followers FollowingRecord[] @relation("Follower")
following FollowingRecord[] @relation("Following")
followers FollowingRecord[] @relation("Follower")
recommendations Recommendation[]
inviteCodeOwner InviteCode[] @relation("InviteCodeOwner")
inviteCodeUsed InviteCode? @relation("InviteCodeUsedBy")
}

model FollowingRecord {
userId String
followerId String
userId String @db.VarChar(64)
followerId String @db.VarChar(64)
createdAt DateTime
@@id([userId, followerId])
Expand All @@ -59,9 +59,9 @@ model FollowingRecord {
}

model Recommendation {
id String @id @default(uuid())
userId String
articleId String
id String @id @db.VarChar(64) @default(uuid())
userId String @db.VarChar(64)
articleId String @db.VarChar(64)
description String
cutoff DateTime
createAt DateTime @default(now())
Expand All @@ -72,7 +72,7 @@ model Recommendation {
}

model Article {
id String @id
id String @id @db.VarChar(64) @default(uuid())
doi String? @db.VarChar(32)
title String @db.VarChar(256)
author String @db.VarChar(256)
Expand All @@ -89,11 +89,11 @@ model Article {
model InviteCode {
id Int @id @default(autoincrement())
code String @db.VarChar(64)
ownerId String @db.VarChar(32)
ownerId String @db.VarChar(64)
issuedAt DateTime @default(now())
usedById String? @db.VarChar(32) @unique
usedById String? @db.VarChar(64) @unique
usedAt DateTime?
owner User @relation("InviteCodeOwner", fields: [ownerId], references: [id])
usedBy User? @relation("InviteCodeUsedBy", fields: [usedById], references: [id])
owner User @relation("InviteCodeOwner", fields: [ownerId], references: [id])
usedBy User? @relation("InviteCodeUsedBy", fields: [usedById], references: [id])
}

0 comments on commit 99a0760

Please sign in to comment.