generator client { provider = "prisma-client-js" } datasource db { provider = "postgresql" url = env("DATABASE_URL") } model User { id Int @id @default(autoincrement()) email String @unique passwordHash String @map("password_hash") displayName String? @map("display_name") createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") @@map("users") } model HostGroup { id Int @id @default(autoincrement()) name String parentId Int? @map("parent_id") sortOrder Int @default(0) @map("sort_order") parent HostGroup? @relation("GroupTree", fields: [parentId], references: [id], onDelete: SetNull) children HostGroup[] @relation("GroupTree") hosts Host[] createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") @@map("host_groups") } model Host { id Int @id @default(autoincrement()) name String hostname String port Int @default(22) protocol Protocol @default(ssh) groupId Int? @map("group_id") credentialId Int? @map("credential_id") tags String[] @default([]) notes String? color String? @db.VarChar(7) sortOrder Int @default(0) @map("sort_order") hostFingerprint String? @map("host_fingerprint") lastConnectedAt DateTime? @map("last_connected_at") group HostGroup? @relation(fields: [groupId], references: [id], onDelete: SetNull) credential Credential? @relation(fields: [credentialId], references: [id], onDelete: SetNull) connectionLogs ConnectionLog[] createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") @@map("hosts") } model Credential { id Int @id @default(autoincrement()) name String username String? domain String? type CredentialType encryptedValue String? @map("encrypted_value") sshKeyId Int? @map("ssh_key_id") sshKey SshKey? @relation(fields: [sshKeyId], references: [id], onDelete: SetNull) hosts Host[] createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") @@map("credentials") } model SshKey { id Int @id @default(autoincrement()) name String keyType String @map("key_type") @db.VarChar(20) fingerprint String? publicKey String? @map("public_key") encryptedPrivateKey String @map("encrypted_private_key") passphraseEncrypted String? @map("passphrase_encrypted") credentials Credential[] createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") @@map("ssh_keys") } model ConnectionLog { id Int @id @default(autoincrement()) hostId Int @map("host_id") protocol Protocol connectedAt DateTime @default(now()) @map("connected_at") disconnectedAt DateTime? @map("disconnected_at") host Host @relation(fields: [hostId], references: [id], onDelete: Cascade) @@map("connection_logs") } model Setting { key String @id value String @@map("settings") } enum Protocol { ssh rdp } enum CredentialType { password ssh_key }