refactor: migrate from MongoDB to SQLite, updating database schema and configuration for improved performance and simplicity

This commit is contained in:
Julien Froidefond
2025-10-24 15:11:29 +02:00
parent 07c6bae2c4
commit ac5fa85185
22 changed files with 278 additions and 219 deletions

View File

@@ -6,15 +6,15 @@ generator client {
}
datasource db {
provider = "mongodb"
url = env("MONGODB_URI")
provider = "sqlite"
url = env("DATABASE_URL")
}
model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
id Int @id @default(autoincrement())
email String @unique
password String
roles String[] @default(["ROLE_USER"])
roles Json @default("[\"ROLE_USER\"]")
authenticated Boolean @default(true)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@ -29,8 +29,8 @@ model User {
}
model KomgaConfig {
id String @id @default(auto()) @map("_id") @db.ObjectId
userId String @unique
id Int @id @default(autoincrement())
userId Int @unique
url String
username String
authHeader String
@@ -43,8 +43,8 @@ model KomgaConfig {
}
model TTLConfig {
id String @id @default(auto()) @map("_id") @db.ObjectId
userId String @unique
id Int @id @default(autoincrement())
userId Int @unique
defaultTTL Int @default(5)
homeTTL Int @default(5)
librariesTTL Int @default(1440)
@@ -61,15 +61,18 @@ model TTLConfig {
}
model Preferences {
id String @id @default(auto()) @map("_id") @db.ObjectId
userId String @unique
showThumbnails Boolean @default(true)
cacheMode String @default("memory") // "memory" | "file"
showOnlyUnread Boolean @default(false)
displayMode Json @default("{\"compact\": false, \"itemsPerPage\": 20}")
background Json @default("{\"type\": \"default\", \"opacity\": 100, \"blur\": 0}")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
id Int @id @default(autoincrement())
userId Int @unique
showThumbnails Boolean @default(true)
cacheMode String @default("memory") // "memory" | "file"
showOnlyUnread Boolean @default(false)
displayMode Json
background Json
komgaMaxConcurrentRequests Int @default(2)
circuitBreakerConfig Json
readerPrefetchCount Int @default(5)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@ -77,8 +80,8 @@ model Preferences {
}
model Favorite {
id String @id @default(auto()) @map("_id") @db.ObjectId
userId String
id Int @id @default(autoincrement())
userId Int
seriesId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt