HomeDocsDevelopmentDatabase Schema
Development

Database Schema

Prisma schema, migrations, and database operations.

bthavanishBy bthavanish

Database Schema

Overview

The database uses PostgreSQL with Prisma ORM. The schema is defined in storage/prisma/schema.prisma.

Models

Role

Roles define permission sets for users.

FieldTypeDescription
idIntAuto-incrementing ID
nameStringUnique internal name
displayNameStringDisplay name
descriptionString?Description
isAdminBooleanGrants admin privileges
permissionsStringJSON array of permission strings
isSystemBooleanPrevents deletion
sortOrderIntDisplay order
createdAtDateTimeCreation timestamp
updatedAtDateTimeLast update timestamp

Users

FieldTypeDescription
idIntAuto-incrementing ID
emailStringUnique email
usernameString?Unique display name
passwordStringbcrypt hash
isAdminBooleanAdmin flag
roleStringRole name (FK)
descriptionString?Bio
avatarString?Avatar URL
permissionsText?JSON permission overrides
serverLimitInt?Max servers
maxMemoryInt?Total memory limit (MB)
maxCpuInt?Total CPU limit
maxStorageInt?Total storage limit (MB)
maxDatabasesInt?Total database limit
preferredNodeIdInt?Preferred node FK
totpEnabledBooleanTOTP 2FA enabled
totpSecretString?TOTP secret
totpRecoveryCodesText?Recovery codes JSON
passkeyEnabledBooleanPasskey 2FA enabled
loginAttemptsIntFailed login count
lockedUntilDateTime?Lockout expiry
onboardingCompletedBooleanOnboarding finished
onboardingSkippedBooleanOnboarding skipped
createdAtDateTimeCreation timestamp
updatedAtDateTimeLast update timestamp

Server

FieldTypeDescription
idIntAuto-incrementing ID
UUIDStringUnique UUID
nameStringDisplay name
descriptionString?Description
PortsTextPort allocation JSON
MemoryIntMemory limit (MB)
SwapIntSwap limit (MB)
CpuIntCPU limit
StorageIntStorage limit (MB)
VariablesText?Environment variables JSON
StartCommandString?Custom startup command
dockerImageString?Docker image override
allowStartupEditBooleanAllow startup editing
InstallingBooleanBeing installed
QueuedBooleanQueued for install
SuspendedBooleanSuspended by admin
RunningBooleanContainer running
backupLimitIntMax backups
backupIgnoreListTextPaths to exclude from backups
databaseLimitIntMax databases
ownerIdIntOwner user FK
nodeIdIntNode FK
imageIdIntImage FK

Node

FieldTypeDescription
idIntAuto-incrementing ID
nameStringDisplay name
ramIntTotal RAM (MB)
cpuIntTotal CPU
diskIntTotal disk (MB)
overallocateMemoryIntMemory overallocation %
overallocateDiskIntDisk overallocation %
overallocateCpuIntCPU overallocation %
locationIdInt?Location FK
addressStringIP or hostname
portIntDaemon port
keyStringShared API key
sftpPortIntSFTP port
maintenanceModeBooleanMaintenance mode

Allocation

Port allocations for servers on nodes.

FieldTypeDescription
idIntAuto-incrementing ID
nodeIdIntNode FK
ipStringIP address
portIntPort number
serverIdString?Assigned server UUID

Backup

FieldTypeDescription
idIntAuto-incrementing ID
UUIDStringUnique UUID
nameStringBackup name
serverIdStringServer UUID FK
filePathStringFile path on node
sizeBigInt?File size
checksumString?Integrity checksum
lockedBooleanLock prevents deletion

DatabaseHost

FieldTypeDescription
idIntAuto-incrementing ID
nameStringDisplay name
hostStringHostname
portIntPostgreSQL port
usernameStringAdmin username
passwordStringAdmin password
nodeIdInt?Associated node

ServerDatabase

FieldTypeDescription
idIntAuto-incrementing ID
serverIdStringServer UUID FK
hostIdIntDatabase host FK
databaseNameStringDatabase name
databaseUserStringDatabase user
databasePasswordStringDatabase password

Schedule

FieldTypeDescription
idIntAuto-incrementing ID
serverIdStringServer UUID FK
nameStringSchedule name
cronStringCron expression
enabledBooleanActive state
timeOffsetIntTime offset
lastRunAtDateTime?Last execution
nextRunAtDateTime?Next scheduled run

ScheduleTask

FieldTypeDescription
idIntAuto-incrementing ID
scheduleIdIntSchedule FK
orderIntExecution order
actionStringTask type
payloadTextAction data
timeOffsetIntDelay before task

Images

FieldTypeDescription
idIntAuto-incrementing ID
UUIDStringUnique UUID
nameString?Display name
descriptionString?Description
authorString?Author
dockerImagesText?Allowed Docker images
startupText?Default startup command
stopText?Stop command
startup_doneText?Startup completion string
config_filesText?Config file paths
variablesText?Variable definitions
statusStringapproved/pending/rejected

Mount

FieldTypeDescription
idIntAuto-incrementing ID
nameStringDisplay name
sourceStringHost path
targetStringContainer path
readOnlyBooleanRead-only mount

ApiKey

FieldTypeDescription
idIntAuto-incrementing ID
nameStringDisplay name
keyStringUnique key value
descriptionString?Description
permissionsTextJSON capability array
activeBooleanActive state
userIdInt?Owner user FK

Other Models

  • PasswordReset (password reset tokens)
  • LoginHistory (login audit log)
  • PlayerStats (player count snapshots)
  • Addon (installed addons)
  • AddonSetting (addon configuration)
  • SftpCredential (SFTP connection details)
  • SubUser (server sub-user access)
  • ActivityLog (audit trail)
  • WebAuthnCredential (passkey credentials)
  • ServerFolder (server folders)
  • ServerFolderMember (folder membership)
  • settings (panel settings, singleton)

Migrations

pnpm run migrate:dev      # Development (creates migration files)
pnpm run migrate:deploy   # Production (applies pending migrations)
pnpm run generate         # Regenerate Prisma client

Relations

Relationships:

  • User to Server (one-to-many, via ownerId)
  • Server to Node (many-to-one, via nodeId)
  • Server to Images (many-to-one, via imageId)
  • Server to Backup (one-to-many)
  • Server to ServerDatabase (one-to-many)
  • Server to Schedule (one-to-many)
  • Server to SubUser (one-to-many)
  • Node to Allocation (one-to-many)
  • Node to Location (many-to-one)
  • DatabaseHost to Node (many-to-one)
  • Role to Users (one-to-many, via role name).