panorama/src-tauri/prisma/schema.prisma
2023-06-12 23:07:03 -05:00

109 lines
2.2 KiB
Text

generator client {
provider = "cargo prisma"
output = "../src/prisma.rs"
}
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
model Node {
id String @id @default(uuid())
label String?
implements NodeImplements[]
fromNodes Edge[] @relation(name: "fromNode")
toNodes Edge[] @relation(name: "toNode")
metadata NodeMeta[]
}
model Interface {
id String @id @default(uuid())
implementors NodeImplements[]
}
model Edge {
id String @id @default(uuid())
label String?
/// The app that created this edge
app App @relation(fields: [appId], references: [id])
appId String
appKey String
fromId String
fromNode Node @relation(name: "fromNode", fields: [fromId], references: [id])
toId String
toNode Node @relation(name: "toNode", fields: [toId], references: [id])
directional Boolean
@@unique([fromId, toId])
@@index([appId, appKey])
}
model NodeMeta {
nodeId String
node Node @relation(fields: [nodeId], references: [id], onDelete: Cascade)
/// The app that created this metadata field
app App @relation(fields: [appId], references: [id])
appId String
appKey String
value Bytes
@@id([nodeId, appId, appKey])
@@index([appId, appKey])
}
model NodeImplements {
nodeId String
node Node @relation(fields: [nodeId], references: [id])
interfaceId String
interface Interface @relation(fields: [interfaceId], references: [id])
@@id([nodeId, interfaceId])
}
model App {
id String @id @default(uuid())
localName String @unique
title String
installed DateTime @default(now())
patterns Patterns[]
metaKeys NodeMeta[]
edges Edge[]
}
/// Regular expressions table
model Patterns {
id String @id @default(uuid())
pattern String
/// Pattern type, see docs for details
type String
appId String
app App @relation(fields: [appId], references: [id])
functionName String
}
/// Index table, for keeping track of indexes to build and take down when the database first starts
model Indices {
id String @id @default(uuid())
command String
// TODO: Does sqlite avoid making duplicate indexes automatically?
}