From 1ae8b3e324f786b51342ca9fed65c465e2f6685a Mon Sep 17 00:00:00 2001 From: headlessdev Date: Mon, 21 Apr 2025 13:25:55 +0200 Subject: [PATCH] server_history model --- agent/main.go | 2 +- .../20250421112542_server_history/migration.sql | 12 ++++++++++++ prisma/schema.prisma | 10 ++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 prisma/migrations/20250421112542_server_history/migration.sql diff --git a/agent/main.go b/agent/main.go index 5be3785..6862dd0 100644 --- a/agent/main.go +++ b/agent/main.go @@ -269,7 +269,7 @@ func getServers(db *sql.DB) []Server { func checkAndUpdateStatus(db *sql.DB, client *http.Client, apps []Application) { var notificationTemplate string - err := db.QueryRow("SELECT notification_text FROM settings LIMIT 1").Scan(¬ificationTemplate) + err := db.QueryRow("SELECT notification_text_application FROM settings LIMIT 1").Scan(¬ificationTemplate) if err != nil || notificationTemplate == "" { notificationTemplate = "The application !name (!url) went !status!" } diff --git a/prisma/migrations/20250421112542_server_history/migration.sql b/prisma/migrations/20250421112542_server_history/migration.sql new file mode 100644 index 0000000..2a14543 --- /dev/null +++ b/prisma/migrations/20250421112542_server_history/migration.sql @@ -0,0 +1,12 @@ +-- CreateTable +CREATE TABLE "server_history" ( + "id" SERIAL NOT NULL, + "serverId" INTEGER NOT NULL DEFAULT 1, + "online" BOOLEAN NOT NULL DEFAULT true, + "cpuUsage" TEXT, + "ramUsage" TEXT, + "diskUsage" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "server_history_pkey" PRIMARY KEY ("id") +); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 9e9bd76..a5f117f 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -32,6 +32,16 @@ model uptime_history { createdAt DateTime @default(now()) } +model server_history { + id Int @id @default(autoincrement()) + serverId Int @default(1) + online Boolean @default(true) + cpuUsage String? + ramUsage String? + diskUsage String? + createdAt DateTime @default(now()) +} + model server { id Int @id @default(autoincrement()) host Boolean @default(false)