98 lines
No EOL
3 KiB
Text
98 lines
No EOL
3 KiB
Text
// This is your Prisma schema file,
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
output = "../src/generated/prisma"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "sqlite"
|
|
url = "file:./dev.db"
|
|
}
|
|
|
|
// URLs table - Each comparison page has its own URL
|
|
model Url {
|
|
id Int @id @default(autoincrement())
|
|
url String @unique
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
// Relations
|
|
items Item[]
|
|
selectedProperties SelectedProperty[]
|
|
deletedProperties DeletedProperty[]
|
|
|
|
@@map("urls")
|
|
}
|
|
|
|
// Properties table - All available properties (core + custom)
|
|
model Property {
|
|
id Int @id @default(autoincrement())
|
|
name String @unique
|
|
globalUsageCount Int @default(0) @map("global_usage_count")
|
|
|
|
// Relations
|
|
itemProperties ItemProperty[]
|
|
selectedProperties SelectedProperty[]
|
|
deletedProperties DeletedProperty[]
|
|
|
|
@@map("properties")
|
|
}
|
|
|
|
// Items table - Individual items that can appear in multiple URLs
|
|
model Item {
|
|
id String @id
|
|
urlId Int @map("url_id")
|
|
wikidataId String? @map("wikidata_id")
|
|
itemOrder Int @default(0) @map("item_order")
|
|
globalItemId String @unique @map("global_item_id")
|
|
|
|
// Relations
|
|
url Url @relation(fields: [urlId], references: [id], onDelete: Cascade)
|
|
itemProperties ItemProperty[] @relation("ItemToItemProperty")
|
|
deletedProperties DeletedProperty[]
|
|
|
|
@@map("items")
|
|
}
|
|
|
|
// Junction table for item properties (including core properties like name, description)
|
|
model ItemProperty {
|
|
globalItemId String @map("global_item_id")
|
|
propertyId Int @map("property_id")
|
|
value String
|
|
|
|
// Relations
|
|
item Item @relation("ItemToItemProperty", fields: [globalItemId], references: [globalItemId], onDelete: Cascade)
|
|
property Property @relation(fields: [propertyId], references: [id], onDelete: Cascade)
|
|
|
|
@@id([globalItemId, propertyId])
|
|
@@map("item_properties")
|
|
}
|
|
|
|
// Selected properties for each URL (excludes core properties)
|
|
model SelectedProperty {
|
|
urlId Int @map("url_id")
|
|
propertyId Int @map("property_id")
|
|
|
|
// Relations
|
|
url Url @relation(fields: [urlId], references: [id], onDelete: Cascade)
|
|
property Property @relation(fields: [propertyId], references: [id], onDelete: Cascade)
|
|
|
|
@@id([urlId, propertyId])
|
|
@@map("selected_properties")
|
|
}
|
|
|
|
// Soft delete tracking for properties per URL
|
|
model DeletedProperty {
|
|
urlId Int @map("url_id")
|
|
globalItemId String @map("global_item_id")
|
|
propertyId Int @map("property_id")
|
|
|
|
// Relations
|
|
url Url @relation(fields: [urlId], references: [id], onDelete: Cascade)
|
|
item Item @relation(fields: [globalItemId], references: [globalItemId], onDelete: Cascade)
|
|
property Property @relation(fields: [propertyId], references: [id], onDelete: Cascade)
|
|
|
|
@@id([urlId, globalItemId, propertyId])
|
|
@@map("deleted_properties")
|
|
} |