* refactor: migrate from better-sqlite3 to Prisma - Install Prisma dependencies and initialize with SQLite - Create Prisma schema matching existing database structure - Replace database.js with Prisma-based database service - Update all API routes, tRPC routers, and WebSocket handler - Convert TypeScript types to match Prisma schema - Update build process to include Prisma migrations - Remove better-sqlite3 dependency All database operations now use Prisma while maintaining SQLite backend. * fix: flatten server data in installed scripts API responses - Transform Prisma nested server objects to flattened fields expected by frontend - Update getAllInstalledScripts, getInstalledScriptsByServer, and getInstalledScriptById - Server names should now display correctly in the installed scripts table - Use nullish coalescing operators for better null handling * fix: ensure DATABASE_URL is set in .env for Prisma during updates - Add ensure_database_url() function to update.sh - Function checks if .env exists and creates from .env.example if needed - Automatically adds DATABASE_URL if not present - Call function after restore_backup_files() in update flow - Fixes Prisma client generation error during updates
46 lines
1.3 KiB
Plaintext
46 lines
1.3 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "sqlite"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model InstalledScript {
|
|
id Int @id @default(autoincrement())
|
|
script_name String
|
|
script_path String
|
|
container_id String?
|
|
server_id Int?
|
|
execution_mode String
|
|
installation_date DateTime? @default(now())
|
|
status String
|
|
output_log String?
|
|
web_ui_ip String?
|
|
web_ui_port Int?
|
|
server Server? @relation(fields: [server_id], references: [id], onDelete: SetNull)
|
|
|
|
@@map("installed_scripts")
|
|
}
|
|
|
|
model Server {
|
|
id Int @id @default(autoincrement())
|
|
name String @unique
|
|
ip String
|
|
user String
|
|
password String?
|
|
auth_type String? @default("password")
|
|
ssh_key String?
|
|
ssh_key_passphrase String?
|
|
ssh_port Int? @default(22)
|
|
color String?
|
|
created_at DateTime? @default(now())
|
|
updated_at DateTime? @updatedAt
|
|
ssh_key_path String?
|
|
key_generated Boolean? @default(false)
|
|
installed_scripts InstalledScript[]
|
|
|
|
@@map("servers")
|
|
}
|