using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace ControlCenter.Api.Migrations { /// public partial class CreateAgentsTable : Migration { /// 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(type: "uuid", nullable: false), status = table.Column(type: "agent_status", nullable: false), task = table.Column(type: "text", nullable: true), progress = table.Column(type: "integer", nullable: true), session_key = table.Column(type: "text", nullable: false), channel = table.Column(type: "text", nullable: false), last_activity = table.Column(type: "timestamptz", nullable: false), created_at = table.Column(type: "timestamptz", nullable: false, defaultValueSql: "now()"), updated_at = table.Column(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"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "agents"); } } }