Skip to content
Merged
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
50 changes: 33 additions & 17 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
generator client {
provider = "prisma-client-js"
provider = "prisma-client-js"
previewFeatures = ["postgresqlExtensions"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_URL")
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_URL")
extensions = [pgvector(map: "vector", schema: "extensions")]
}

enum RESOURCE_TYPE {
Expand Down Expand Up @@ -75,7 +77,8 @@ model Resource {
externalResources ExternalResources?
collectionItems CollectionItem[]
internalResource InternalHostedResources?
image_s3_key String?
image_s3_key String?
ResourceEmbedding ResourceEmbedding?

@@map("resource")
}
Expand All @@ -84,7 +87,7 @@ model ResourceLabel {
id String @id @default(cuid())
resource_id String
label_id String
resource Resource @relation(fields: [resource_id], references: [id], onDelete:Cascade)
resource Resource @relation(fields: [resource_id], references: [id], onDelete: Cascade)
label CategoryLabel @relation(fields: [label_id], references: [id])

@@unique([resource_id, label_id])
Expand All @@ -100,6 +103,20 @@ model ExternalResources {
@@map("externalResources")
}

model ResourceEmbedding {
id String @id @default(cuid())
resource_id String @unique
embedding Unsupported("vector(1536)")
dims Int @default(1536)
chunk_text String
chunk_index Int
created_at DateTime @default(now())
updated_at DateTime @updatedAt
resource Resource @relation(fields: [resource_id], references: [id], onDelete: Cascade)

@@map("resourceEmbedding")
}

enum RELATIONSHIP_TYPE {
MOTHER
FATHER
Expand All @@ -119,24 +136,24 @@ enum HOUSEHOLD_TYPE {
}

model Parent {
id String @id @default(cuid())
clerk_id String @unique
id String @id @default(cuid())
clerk_id String @unique
first_name String?
last_name String?
email String @unique
email String @unique

relationship RELATIONSHIP_TYPE?
household_type HOUSEHOLD_TYPE?
topics_of_interest CATEGORY_TYPE[]
kids_age_groups AGE_GROUP[]
subscribed_newsletter Boolean @default(false)

created_at DateTime @default(now())
updated_at DateTime @updatedAt
onboarding_complete Boolean @default(false)
created_at DateTime @default(now())
updated_at DateTime @updatedAt
onboarding_complete Boolean @default(false)

collections Collection[]

collections Collection[]
@@map("parent")
}

Expand All @@ -147,8 +164,8 @@ model Collection {
created_at DateTime @default(now())
updated_at DateTime @updatedAt

parent Parent @relation(fields: [parent_fk], references: [id], onDelete: Cascade)
items CollectionItem[]
parent Parent @relation(fields: [parent_fk], references: [id], onDelete: Cascade)
items CollectionItem[]

@@unique([parent_fk, name])
@@map("collection")
Expand Down Expand Up @@ -176,7 +193,6 @@ model InternalHostedResources {
@@map("internalHostedResources")
}


model AdminUser {
id String @id @default(cuid())
clerk_id String @unique
Expand All @@ -203,4 +219,4 @@ model AdminLog {

@@index([admin_fk])
@@map("adminlog")
}
}
Loading