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