From f2d0924bca83360a74f6278c19b959fd0db40844 Mon Sep 17 00:00:00 2001 From: lorsan Date: Wed, 6 May 2026 21:38:58 +0300 Subject: [PATCH] feat: new table heartbeats --- .../20260506182346_create_heartbeat_table.down.sql | 3 +++ .../20260506182346_create_heartbeat_table.up.sql | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100644 hub/internal/migrations/20260506182346_create_heartbeat_table.down.sql create mode 100644 hub/internal/migrations/20260506182346_create_heartbeat_table.up.sql diff --git a/hub/internal/migrations/20260506182346_create_heartbeat_table.down.sql b/hub/internal/migrations/20260506182346_create_heartbeat_table.down.sql new file mode 100644 index 0000000..d8cc83d --- /dev/null +++ b/hub/internal/migrations/20260506182346_create_heartbeat_table.down.sql @@ -0,0 +1,3 @@ +DROP INDEX idx_heartbeat_agent_id; + +DROP TABLE if exists heartbeats; \ No newline at end of file diff --git a/hub/internal/migrations/20260506182346_create_heartbeat_table.up.sql b/hub/internal/migrations/20260506182346_create_heartbeat_table.up.sql new file mode 100644 index 0000000..e848921 --- /dev/null +++ b/hub/internal/migrations/20260506182346_create_heartbeat_table.up.sql @@ -0,0 +1,11 @@ +CREATE TABLE heartbeats ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + agent_id VARCHAR(32) UNIQUE NOT NULL, + cpu_usage FLOAT, + memory_usage FLOAT, + disk_usage FLOAT, + heartbeat_timestamp TIMESTAMP + FOREIGN KEY (agent_id) REFERENCES agents(id) ON DELETE CASCADE +); + +CREATE UNIQUE INDEX idx_heartbeat_agent_id ON heartbeats (agent_id); \ No newline at end of file