Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
team database model
Aashish-Upadhyay-1017170a24e39e9
diff --git a/prisma/schema.prisma b/prisma/schema.prismaindex 38e071c6..2343e17e 100644--- a/prisma/schema.prisma+++ b/prisma/schema.prisma@@ -1,28 +1,28 @@datasource db {- provider = "postgresql"- url = env("POSTGRES_PRISMA_URL") // uses connection pooling+ provider = "postgresql"+ url = env("POSTGRES_PRISMA_URL") // uses connection pooling// url = env("POSTGRES_PRISMA_URL_NON_POOLING") // uses a direct connection- directUrl = env("POSTGRES_PRISMA_URL_NON_POOLING") // uses a direct connection+ directUrl = env("POSTGRES_PRISMA_URL_NON_POOLING") // uses a direct connectionshadowDatabaseUrl = env("POSTGRES_PRISMA_URL_NON_POOLING") // used for migrations- }+}generator client {- provider = "prisma-client-js"+ provider = "prisma-client-js"}model Account {- id String @id @default(cuid())- userId String- type String- provider String- providerAccountId String- refresh_token String? @db.Text- access_token String? @db.Text- expires_at Int?- token_type String?- scope String?- id_token String? @db.Text- session_state String?+ id String @id @default(cuid())+ userId String+ type String+ provider String+ providerAccountId String+ refresh_token String? @db.Text+ access_token String? @db.Text+ expires_at Int?+ token_type String?+ scope String?+ id_token String? @db.Text+ session_state String?user User @relation(fields: [userId], references: [id], onDelete: Cascade)@@ -38,21 +38,52 @@ model Session {}model User {- id String @id @default(cuid())- name String?- email String? @unique- emailVerified DateTime?- image String?- createdAt DateTime @default(now())- accounts Account[]- sessions Session[]- documents Document[]- domains Domain[]- plan String @default("free")- stripeId String? @unique // Stripe subscription / customer ID- subscriptionId String? @unique // Stripe subscription ID- startsAt DateTime? // Stripe subscription start date- endsAt DateTime? // Stripe subscription end date+ id String @id @default(cuid())+ name String?+ email String? @unique+ emailVerified DateTime?+ image String?+ createdAt DateTime @default(now())+ accounts Account[]+ sessions Session[]+ documents Document[]+ teams UserTeam[]+ domains Domain[]+ plan String @default("free")+ stripeId String? @unique // Stripe subscription / customer ID+ subscriptionId String? @unique // Stripe subscription ID+ startsAt DateTime? // Stripe subscription start date+ endsAt DateTime? // Stripe subscription end date+}++model Team {+ id String @id @default(cuid())+ name String+ users UserTeam[]+ documents Document[]+ domains Domain[]+ plan String @default("free")+ stripeId String? @unique // Stripe subscription / customer ID+ subscriptionId String? @unique // Stripe subscription ID+ startsAt DateTime? // Stripe subscription start date+ endsAt DateTime? // Stripe subscription end date+ createdAt DateTime @default(now())+ updatedAt DateTime @updatedAt+}++enum Role {+ ADMIN+ MEMBER+}++model UserTeam {+ role Role @default(MEMBER)+ userId String+ teamId String+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)+ team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)++ @@id([userId, teamId])}model VerificationToken {@@ -64,68 +95,70 @@ model VerificationToken {}model Document {- id String @id @default(cuid())- name String+ id String @id @default(cuid())+ name Stringdescription String?- file String // This should be a reference to where the file is stored (S3, Google Cloud Storage, etc.)- type String? // This should be a reference to the file type (pdf, docx, etc.)- numPages Int? // This should be a reference to the number of pages in the document- owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)- ownerId String // This field holds the foreign key.- createdAt DateTime @default(now())- updatedAt DateTime @updatedAt- links Link[]- views View[]- versions DocumentVersion[]+ file String // This should be a reference to where the file is stored (S3, Google Cloud Storage, etc.)+ type String? // This should be a reference to the file type (pdf, docx, etc.)+ numPages Int? // This should be a reference to the number of pages in the document+ owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)+ teamId String?+ Team Team? @relation(fields: [teamId], references: [id])+ ownerId String // This field holds the foreign key.+ createdAt DateTime @default(now())+ updatedAt DateTime @updatedAt+ links Link[]+ views View[]+ versions DocumentVersion[]}model DocumentVersion {- id String @id @default(cuid())- versionNumber Int // e.g., 1, 2, 3 for version control- document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)- documentId String- file String // This should be a reference to where the file is stored (S3, Google Cloud Storage, etc.)- type String? // This should be a reference to the file type (pdf, docx, etc.)- numPages Int? // This should be a reference to the number of pages in the document- isPrimary Boolean @default(false) // Indicates if this is the primary version- pages DocumentPage[]- hasPages Boolean @default(false) // Indicates if the document has pages- createdAt DateTime @default(now())- updatedAt DateTime @updatedAt+ id String @id @default(cuid())+ versionNumber Int // e.g., 1, 2, 3 for version control+ document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)+ documentId String+ file String // This should be a reference to where the file is stored (S3, Google Cloud Storage, etc.)+ type String? // This should be a reference to the file type (pdf, docx, etc.)+ numPages Int? // This should be a reference to the number of pages in the document+ isPrimary Boolean @default(false) // Indicates if this is the primary version+ pages DocumentPage[]+ hasPages Boolean @default(false) // Indicates if the document has pages+ createdAt DateTime @default(now())+ updatedAt DateTime @updatedAt@@unique([versionNumber, documentId])}model DocumentPage {- id String @id @default(cuid())- version DocumentVersion @relation(fields: [versionId], references: [id], onDelete: Cascade)- versionId String- pageNumber Int // e.g., 1, 2, 3 for- file String // This should be a reference to where the file / page is stored (S3, Google Cloud Storage, etc.)- createdAt DateTime @default(now())- updatedAt DateTime @updatedAt+ id String @id @default(cuid())+ version DocumentVersion @relation(fields: [versionId], references: [id], onDelete: Cascade)+ versionId String+ pageNumber Int // e.g., 1, 2, 3 for+ file String // This should be a reference to where the file / page is stored (S3, Google Cloud Storage, etc.)+ createdAt DateTime @default(now())+ updatedAt DateTime @updatedAt@@unique([pageNumber, versionId])}model Link {- id String @id @default(cuid())- document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)- documentId String- url String? @unique- name String? // Link name- slug String? // Link slug for pretty URLs- expiresAt DateTime? // Optional expiration date- password String? // Optional password for link protection- allowedEmails String[] // Array of emails allowed to view the document- emailProtected Boolean @default(true) // Optional email protection- isArchived Boolean @default(false) // Indicates if the link is archived- views View[]- domain Domain? @relation(fields: [domainId], references: [id], onDelete: SetNull)- domainId String? // This can be nullable, representing links without custom domains- domainSlug String? // This will store the domain's slug even if the domain is deleted- createdAt DateTime @default(now())- updatedAt DateTime @updatedAt+ id String @id @default(cuid())+ document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)+ documentId String+ url String? @unique+ name String? // Link name+ slug String? // Link slug for pretty URLs+ expiresAt DateTime? // Optional expiration date+ password String? // Optional password for link protection+ allowedEmails String[] // Array of emails allowed to view the document+ emailProtected Boolean @default(true) // Optional email protection+ isArchived Boolean @default(false) // Indicates if the link is archived+ views View[]+ domain Domain? @relation(fields: [domainId], references: [id], onDelete: SetNull)+ domainId String? // This can be nullable, representing links without custom domains+ domainSlug String? // This will store the domain's slug even if the domain is deleted+ createdAt DateTime @default(now())+ updatedAt DateTime @updatedAt@@unique([domainSlug, slug])}@@ -135,20 +168,21 @@ model Domain {slug String @uniqueuser User @relation(fields: [userId], references: [id], onDelete: Cascade)userId String+ teamId String?+ Team Team? @relation(fields: [teamId], references: [id])verified Boolean @default(false) // Whether the domain has been verifiedlastChecked DateTime @default(now())createdAt DateTime @default(now())updatedAt DateTime @updatedAt- links Link[] // links associated with this domain+ links Link[] // links associated with this domain}-model View {- id String @id @default(cuid())- link Link @relation(fields: [linkId], references: [id])+ id String @id @default(cuid())+ link Link @relation(fields: [linkId], references: [id])linkId String- document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)+ document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)documentId String- viewerEmail String? // Email of the viewer if known- viewedAt DateTime @default(now())+ viewerEmail String? // Email of the viewer if known+ viewedAt DateTime @default(now())}