Files
Heimdall/src/Heimdall.Infrastructure/Migrations/20261025080000_AddAgentMetricSamples.cs
T
Arnaud Dartois c8c84f0e2c
Heimdall Gitea / Build and tests (pull_request) Failing after 3m28s
Heimdall Gitea / Build and scan server image (pull_request) Skipped
Heimdall Gitea / Build and scan agent image (pull_request) Skipped
Heimdall Gitea / Publish Docker Hub latest tags (pull_request) Skipped
Heimdall Gitea / Publish versioned release (pull_request) Skipped
feat(inventory): add metric history dashboards
2026-10-25 02:19:01 +02:00

72 lines
3.3 KiB
C#

using Heimdall.Infrastructure.Data;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Heimdall.Infrastructure.Migrations;
[DbContext(typeof(AppDbContext))]
[Migration("20261025080000_AddAgentMetricSamples")]
public sealed class AddAgentMetricSamples : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "InventoryObservedAtUtc",
table: "agents",
type: "timestamp with time zone",
nullable: true);
migrationBuilder.CreateTable(
name: "agent_metric_samples",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
AgentId = table.Column<Guid>(type: "uuid", nullable: false),
SiteId = table.Column<Guid>(type: "uuid", nullable: false),
CapturedAtUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
LogicalCores = table.Column<int>(type: "integer", nullable: true),
CpuUsagePercent = table.Column<double>(type: "double precision", nullable: true),
MemoryUsageBytes = table.Column<long>(type: "bigint", nullable: true),
MemTotalBytes = table.Column<long>(type: "bigint", nullable: true),
MemAvailableBytes = table.Column<long>(type: "bigint", nullable: true),
DiskUsagePercent = table.Column<double>(type: "double precision", nullable: true),
GpuTemperatureCelsius = table.Column<double>(type: "double precision", nullable: true),
GpuUtilizationPercent = table.Column<double>(type: "double precision", nullable: true),
TemperatureJson = table.Column<string>(type: "text", nullable: true),
InventoryObservedAtUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_agent_metric_samples", x => x.Id);
table.ForeignKey(
name: "FK_agent_metric_samples_agents_AgentId",
column: x => x.AgentId,
principalTable: "agents",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_agent_metric_samples_AgentId_CapturedAtUtc",
table: "agent_metric_samples",
columns: new[] { "AgentId", "CapturedAtUtc" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_agent_metric_samples_CapturedAtUtc",
table: "agent_metric_samples",
column: "CapturedAtUtc");
migrationBuilder.CreateIndex(
name: "IX_agent_metric_samples_SiteId_CapturedAtUtc",
table: "agent_metric_samples",
columns: new[] { "SiteId", "CapturedAtUtc" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(name: "agent_metric_samples");
migrationBuilder.DropColumn(name: "InventoryObservedAtUtc", table: "agents");
}
}