Files
Control-Center/backend/Migrations/20260426101703_CreateAgentsTable.cs
2026-04-26 10:18:06 +00:00

62 lines
2.4 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ControlCenter.Api.Migrations
{
/// <inheritdoc />
public partial class CreateAgentsTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.Annotation("Npgsql:Enum:agent_status", "active,idle,thinking,error");
migrationBuilder.CreateTable(
name: "agents",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
status = table.Column<int>(type: "agent_status", nullable: false),
task = table.Column<string>(type: "text", nullable: true),
progress = table.Column<int>(type: "integer", nullable: true),
session_key = table.Column<string>(type: "text", nullable: false),
channel = table.Column<string>(type: "text", nullable: false),
last_activity = table.Column<DateTime>(type: "timestamptz", nullable: false),
created_at = table.Column<DateTime>(type: "timestamptz", nullable: false, defaultValueSql: "now()"),
updated_at = table.Column<DateTime>(type: "timestamptz", nullable: false, defaultValueSql: "now()")
},
constraints: table =>
{
table.PrimaryKey("PK_agents", x => x.id);
table.CheckConstraint("ck_agents_progress_range", "progress IS NULL OR (progress >= 0 AND progress <= 100)");
});
migrationBuilder.CreateIndex(
name: "ix_agents_channel",
table: "agents",
column: "channel");
migrationBuilder.CreateIndex(
name: "ix_agents_session_key",
table: "agents",
column: "session_key",
unique: true);
migrationBuilder.CreateIndex(
name: "ix_agents_status",
table: "agents",
column: "status");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "agents");
}
}
}