mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-22 15:40:07 -04:00
310 lines
9.3 KiB
Plaintext
310 lines
9.3 KiB
Plaintext
datasource db {
|
|
provider = "sqlite"
|
|
url = "file:dev.db"
|
|
}
|
|
|
|
generator client {
|
|
provider = "cargo prisma"
|
|
output = "../src/prisma.rs"
|
|
}
|
|
|
|
model Migration {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
checksum String @unique
|
|
steps_applied Int @default(0)
|
|
applied_at DateTime @default(now())
|
|
|
|
@@map("_migrations")
|
|
}
|
|
|
|
model SyncEvent {
|
|
id Int @id @default(autoincrement())
|
|
client_id Int
|
|
timestamp String
|
|
data String
|
|
client Client @relation(fields: [client_id], references: [id])
|
|
|
|
@@map("sync_events")
|
|
}
|
|
|
|
model Library {
|
|
id Int @id @default(autoincrement())
|
|
pub_id String @unique
|
|
name String
|
|
remote_id String?
|
|
is_primary Boolean @default(true)
|
|
encryption Int @default(0)
|
|
date_created DateTime @default(now())
|
|
timezone String?
|
|
spaces Space[]
|
|
|
|
@@map("libraries")
|
|
}
|
|
|
|
model LibraryStatistics {
|
|
id Int @id @default(autoincrement())
|
|
date_captured DateTime @default(now())
|
|
library_id Int @unique
|
|
total_file_count Int @default(0)
|
|
total_bytes_used String @default("0")
|
|
total_bytes_capacity String @default("0")
|
|
total_unique_bytes String @default("0")
|
|
total_bytes_free String @default("0")
|
|
preview_media_bytes String @default("0")
|
|
|
|
@@map("library_statistics")
|
|
}
|
|
|
|
model Client {
|
|
id Int @id @default(autoincrement())
|
|
pub_id String @unique
|
|
name String
|
|
platform Int @default(0)
|
|
version String?
|
|
online Boolean? @default(true)
|
|
last_seen DateTime @default(now())
|
|
timezone String?
|
|
date_created DateTime @default(now())
|
|
|
|
sync_events SyncEvent[]
|
|
jobs Job[]
|
|
|
|
@@map("clients")
|
|
}
|
|
|
|
model Location {
|
|
id Int @id @default(autoincrement())
|
|
pub_id String @unique
|
|
client_id Int?
|
|
name String?
|
|
local_path String?
|
|
total_capacity Int?
|
|
available_capacity Int?
|
|
filesystem String?
|
|
disk_type Int?
|
|
is_removable Boolean?
|
|
is_online Boolean @default(true)
|
|
date_created DateTime @default(now())
|
|
|
|
file_paths FilePath[]
|
|
@@map("locations")
|
|
}
|
|
|
|
model File {
|
|
id Int @id @default(autoincrement())
|
|
// content addressable storage id - sha256
|
|
// this does not need to be unique, as incoming replicas will always ignore if at least one exists
|
|
cas_id String @unique
|
|
// full byte contents digested into sha256 checksum
|
|
integrity_checksum String? @unique
|
|
// basic metadata
|
|
kind Int @default(0)
|
|
size_in_bytes String
|
|
// mark uniqely as encrypted, will lead to all file paths being encrypted
|
|
encryption Int @default(0)
|
|
// handy ways to mark a file
|
|
hidden Boolean @default(false)
|
|
favorite Boolean @default(false)
|
|
important Boolean @default(false)
|
|
// if we have generated preview media for this file
|
|
has_thumbnail Boolean @default(false)
|
|
has_thumbstrip Boolean @default(false)
|
|
has_video_preview Boolean @default(false)
|
|
// integration with ipfs
|
|
ipfs_id String?
|
|
// plain text comment
|
|
comment String?
|
|
// the original known creation date of this file
|
|
date_created DateTime @default(now())
|
|
// the last time this file was modified
|
|
date_modified DateTime @default(now())
|
|
// when this file was first indexed
|
|
date_indexed DateTime @default(now())
|
|
|
|
tags TagOnFile[]
|
|
labels LabelOnFile[]
|
|
albums FileInAlbum[]
|
|
paths FilePath[]
|
|
comments Comment[]
|
|
media_data MediaData?
|
|
|
|
@@map("files")
|
|
}
|
|
|
|
model FilePath {
|
|
id Int @id @default(autoincrement())
|
|
is_dir Boolean @default(false)
|
|
// location that owns this path
|
|
location_id Int
|
|
// a path generated from local file_path ids eg: "34/45/67/890"
|
|
materialized_path String
|
|
// the name and extension
|
|
name String
|
|
extension String?
|
|
// the unique File for this file path
|
|
file_id Int?
|
|
//
|
|
parent_id Int?
|
|
encryption Int @default(0)
|
|
permissions String?
|
|
temp_cas_id String? // so a filepath can be created without its File, as they're created lazily
|
|
|
|
date_created DateTime @default(now())
|
|
date_modified DateTime @default(now())
|
|
date_indexed DateTime @default(now())
|
|
|
|
file File? @relation(fields: [file_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
|
location Location? @relation(fields: [location_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
|
parent FilePath? @relation("directory_file_paths", fields: [parent_id], references: [id])
|
|
children FilePath[] @relation("directory_file_paths")
|
|
|
|
@@unique([location_id, materialized_path, name, extension])
|
|
@@map("file_paths")
|
|
}
|
|
|
|
// if there is a conflicting cas_id, the conficting file should be updated to have a larger cas_id as the feild is unique, however this record is kept to tell the indexer (upon discovering this CAS) that there is alternate versions of the file and to check by a full integrity hash to define for which to associate with.
|
|
model FileConflict {
|
|
original_file_id Int @unique
|
|
detactched_file_id Int @unique
|
|
}
|
|
|
|
model MediaData {
|
|
id Int @id
|
|
pixel_width Int?
|
|
pixel_height Int?
|
|
longitude Float?
|
|
latitude Float?
|
|
fps Int?
|
|
capture_device_make String? // eg: "Apple"
|
|
capture_device_model String? // eg: "iPhone 12"
|
|
capture_device_software String? // eg: "12.1.1"
|
|
duration_seconds Int?
|
|
codecs String? // eg: "h264,acc"
|
|
streams Int?
|
|
|
|
// change this relation to File after testing
|
|
files File? @relation(fields: [id], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
|
|
|
@@map("media_data")
|
|
}
|
|
|
|
model Tag {
|
|
id Int @id @default(autoincrement())
|
|
pub_id String @unique
|
|
name String?
|
|
encryption Int? @default(0)
|
|
total_files Int? @default(0)
|
|
redundancy_goal Int? @default(1)
|
|
date_created DateTime @default(now())
|
|
date_modified DateTime @default(now())
|
|
|
|
tag_files TagOnFile[]
|
|
@@map("tags")
|
|
}
|
|
|
|
model TagOnFile {
|
|
date_created DateTime @default(now())
|
|
|
|
tag_id Int
|
|
tag Tag @relation(fields: [tag_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
|
|
|
file_id Int
|
|
file File @relation(fields: [file_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
|
|
|
@@id([tag_id, file_id])
|
|
@@map("tags_on_files")
|
|
}
|
|
|
|
model Label {
|
|
id Int @id @default(autoincrement())
|
|
pub_id String @unique
|
|
name String?
|
|
date_created DateTime @default(now())
|
|
date_modified DateTime @default(now())
|
|
|
|
label_files LabelOnFile[]
|
|
@@map("labels")
|
|
}
|
|
|
|
model LabelOnFile {
|
|
date_created DateTime @default(now())
|
|
|
|
label_id Int
|
|
label Label @relation(fields: [label_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
|
|
|
file_id Int
|
|
file File @relation(fields: [file_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
|
|
|
@@id([label_id, file_id])
|
|
@@map("label_on_files")
|
|
}
|
|
|
|
model Job {
|
|
id String @id
|
|
client_id Int
|
|
action Int
|
|
status Int @default(0)
|
|
|
|
task_count Int @default(1)
|
|
completed_task_count Int @default(0)
|
|
date_created DateTime @default(now())
|
|
date_modified DateTime @default(now())
|
|
seconds_elapsed Int @default(0)
|
|
|
|
clients Client @relation(fields: [client_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
|
@@map("jobs")
|
|
}
|
|
|
|
model Space {
|
|
id Int @id @default(autoincrement())
|
|
pub_id String @unique
|
|
name String
|
|
encryption Int? @default(0) // remove
|
|
date_created DateTime @default(now())
|
|
date_modified DateTime @default(now())
|
|
Library Library? @relation(fields: [libraryId], references: [id])
|
|
libraryId Int?
|
|
|
|
@@map("spaces")
|
|
}
|
|
|
|
model Album {
|
|
id Int @id @default(autoincrement())
|
|
pub_id String @unique
|
|
name String
|
|
is_hidden Boolean @default(false)
|
|
|
|
date_created DateTime @default(now())
|
|
date_modified DateTime @default(now())
|
|
|
|
files FileInAlbum[]
|
|
|
|
@@map("albums")
|
|
}
|
|
|
|
model FileInAlbum {
|
|
date_created DateTime @default(now())
|
|
|
|
album_id Int
|
|
album Album @relation(fields: [album_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
|
|
|
file_id Int
|
|
file File @relation(fields: [file_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
|
|
|
@@id([album_id, file_id])
|
|
@@map("files_in_albums")
|
|
}
|
|
|
|
model Comment {
|
|
id Int @id @default(autoincrement())
|
|
pub_id String @unique
|
|
content String
|
|
date_created DateTime @default(now())
|
|
date_modified DateTime @default(now())
|
|
file_id Int?
|
|
file File? @relation(fields: [file_id], references: [id])
|
|
|
|
@@map("comments")
|
|
}
|