// <auto-generated />
using System;
using ControlCenter.Api.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

#nullable disable

namespace ControlCenter.Api.Migrations
{
    [DbContext(typeof(AppDbContext))]
    [Migration("20260426101703_CreateAgentsTable")]
    partial class CreateAgentsTable
    {
        /// <inheritdoc />
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
#pragma warning disable 612, 618
            modelBuilder
                .HasAnnotation("ProductVersion", "9.0.4")
                .HasAnnotation("Relational:MaxIdentifierLength", 63);

            NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "agent_status", new[] { "active", "idle", "thinking", "error" });
            NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);

            modelBuilder.Entity("ControlCenter.Api.Entities.Agent", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid")
                        .HasColumnName("id");

                    b.Property<string>("Channel")
                        .IsRequired()
                        .HasColumnType("text")
                        .HasColumnName("channel");

                    b.Property<DateTime>("CreatedAt")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("timestamptz")
                        .HasColumnName("created_at")
                        .HasDefaultValueSql("now()");

                    b.Property<DateTime>("LastActivity")
                        .HasColumnType("timestamptz")
                        .HasColumnName("last_activity");

                    b.Property<int?>("Progress")
                        .HasColumnType("integer")
                        .HasColumnName("progress");

                    b.Property<string>("SessionKey")
                        .IsRequired()
                        .HasColumnType("text")
                        .HasColumnName("session_key");

                    b.Property<int>("Status")
                        .HasColumnType("agent_status")
                        .HasColumnName("status");

                    b.Property<string>("Task")
                        .HasColumnType("text")
                        .HasColumnName("task");

                    b.Property<DateTime>("UpdatedAt")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("timestamptz")
                        .HasColumnName("updated_at")
                        .HasDefaultValueSql("now()");

                    b.HasKey("Id");

                    b.HasIndex("Channel")
                        .HasDatabaseName("ix_agents_channel");

                    b.HasIndex("SessionKey")
                        .IsUnique()
                        .HasDatabaseName("ix_agents_session_key");

                    b.HasIndex("Status")
                        .HasDatabaseName("ix_agents_status");

                    b.ToTable("agents", null, t =>
                        {
                            t.HasCheckConstraint("ck_agents_progress_range", "progress IS NULL OR (progress >= 0 AND progress <= 100)");
                        });
                });
#pragma warning restore 612, 618
        }
    }
}
