diff --git a/apps/recnet-api/prisma/migrations/20240306035932_init/migration.sql b/apps/recnet-api/prisma/migrations/20240306064817_init/migration.sql similarity index 91% rename from apps/recnet-api/prisma/migrations/20240306035932_init/migration.sql rename to apps/recnet-api/prisma/migrations/20240306064817_init/migration.sql index 921da429..9d69e0b8 100644 --- a/apps/recnet-api/prisma/migrations/20240306035932_init/migration.sql +++ b/apps/recnet-api/prisma/migrations/20240306064817_init/migration.sql @@ -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, @@ -26,8 +26,8 @@ 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") @@ -35,9 +35,9 @@ CREATE TABLE "FollowingRecord" ( -- 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, @@ -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, @@ -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") diff --git a/apps/recnet-api/prisma/schema.prisma b/apps/recnet-api/prisma/schema.prisma index 7afc3102..acb76369 100644 --- a/apps/recnet-api/prisma/schema.prisma +++ b/apps/recnet-api/prisma/schema.prisma @@ -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 @@ -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]) @@ -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()) @@ -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) @@ -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]) }