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

#nullable disable

namespace Nexus.Api.Data.Migrations
{
    [DbContext(typeof(NexusDbContext))]
    [Migration("20260730191613_AddOpenClawConnectionProfile")]
    partial class AddOpenClawConnectionProfile
    {
        /// <inheritdoc />
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
#pragma warning disable 612, 618
            modelBuilder
                .HasAnnotation("ProductVersion", "10.0.8")
                .HasAnnotation("Relational:MaxIdentifierLength", 63);

            NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);

            modelBuilder.Entity("Nexus.Api.Data.ActivityEvent", b =>
                {
                    b.Property<long>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("bigint");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));

                    b.Property<DateTimeOffset>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("Message")
                        .IsRequired()
                        .HasMaxLength(1000)
                        .HasColumnType("character varying(1000)");

                    b.Property<Guid?>("TaskId")
                        .HasColumnType("uuid");

                    b.Property<string>("Type")
                        .IsRequired()
                        .HasColumnType("text");

                    b.HasKey("Id");

                    b.HasIndex("CreatedAt");

                    b.HasIndex("TaskId");

                    b.ToTable("Activity");
                });

            modelBuilder.Entity("Nexus.Api.Data.NexusUser", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<DateTimeOffset>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("DisplayName")
                        .IsRequired()
                        .HasMaxLength(100)
                        .HasColumnType("character varying(100)");

                    b.Property<string>("Email")
                        .IsRequired()
                        .HasMaxLength(120)
                        .HasColumnType("character varying(120)");

                    b.Property<DateTimeOffset?>("LastLoginAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("NormalizedEmail")
                        .IsRequired()
                        .HasMaxLength(120)
                        .HasColumnType("character varying(120)");

                    b.Property<string>("PasswordHash")
                        .IsRequired()
                        .HasColumnType("text");

                    b.Property<string>("Role")
                        .IsRequired()
                        .HasColumnType("text");

                    b.Property<DateTimeOffset>("UpdatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.HasKey("Id");

                    b.HasIndex("NormalizedEmail")
                        .IsUnique();

                    b.ToTable("Users");
                });

            modelBuilder.Entity("Nexus.Api.Data.Notification", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<DateTimeOffset>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("ForUser")
                        .IsRequired()
                        .HasMaxLength(60)
                        .HasColumnType("character varying(60)");

                    b.Property<bool>("IsRead")
                        .HasColumnType("boolean");

                    b.Property<string>("Message")
                        .HasMaxLength(1000)
                        .HasColumnType("character varying(1000)");

                    b.Property<Guid?>("TaskId")
                        .HasColumnType("uuid");

                    b.Property<string>("Title")
                        .IsRequired()
                        .HasMaxLength(240)
                        .HasColumnType("character varying(240)");

                    b.Property<string>("Type")
                        .IsRequired()
                        .HasMaxLength(60)
                        .HasColumnType("character varying(60)");

                    b.HasKey("Id");

                    b.HasIndex("ForUser", "IsRead", "CreatedAt");

                    b.ToTable("Notifications");
                });

            modelBuilder.Entity("Nexus.Api.Data.OpenClawConnectionProfile", b =>
                {
                    b.Property<string>("ProfileId")
                        .HasMaxLength(40)
                        .HasColumnType("character varying(40)");

                    b.Property<DateTimeOffset?>("AdoptedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("AdoptionState")
                        .IsRequired()
                        .HasMaxLength(40)
                        .HasColumnType("character varying(40)");

                    b.Property<string>("CapabilityHash")
                        .HasMaxLength(128)
                        .HasColumnType("character varying(128)");

                    b.Property<DateTimeOffset>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("DeviceId")
                        .HasMaxLength(240)
                        .HasColumnType("character varying(240)");

                    b.Property<string>("DiscoverySource")
                        .IsRequired()
                        .HasMaxLength(80)
                        .HasColumnType("character varying(80)");

                    b.Property<string>("Endpoint")
                        .IsRequired()
                        .HasMaxLength(2048)
                        .HasColumnType("character varying(2048)");

                    b.Property<DateTimeOffset?>("LastProbedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<DateTimeOffset?>("LastVerifiedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<bool>("ManagementEnabled")
                        .HasColumnType("boolean");

                    b.Property<string>("RequiredVersion")
                        .HasMaxLength(120)
                        .HasColumnType("character varying(120)");

                    b.Property<int>("Revision")
                        .IsConcurrencyToken()
                        .HasColumnType("integer");

                    b.Property<string>("TlsCertificateFingerprint")
                        .HasMaxLength(128)
                        .HasColumnType("character varying(128)");

                    b.Property<DateTimeOffset>("UpdatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.HasKey("ProfileId");

                    b.ToTable("OpenClawConnectionProfiles", null, t =>
                        {
                            t.HasCheckConstraint("CK_OpenClawConnectionProfiles_Primary", "\"ProfileId\" = 'primary'");
                        });
                });

            modelBuilder.Entity("Nexus.Api.Data.OpenClawRun", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<string>("Actor")
                        .IsRequired()
                        .HasMaxLength(240)
                        .HasColumnType("character varying(240)");

                    b.Property<string>("AgentId")
                        .IsRequired()
                        .HasMaxLength(200)
                        .HasColumnType("character varying(200)");

                    b.Property<string>("CorrelationId")
                        .IsRequired()
                        .HasMaxLength(200)
                        .HasColumnType("character varying(200)");

                    b.Property<DateTimeOffset>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<DateTimeOffset?>("FinishedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("LastError")
                        .HasMaxLength(2000)
                        .HasColumnType("character varying(2000)");

                    b.Property<long?>("LastGatewaySequence")
                        .HasColumnType("bigint");

                    b.Property<string>("OpenClawRunId")
                        .HasMaxLength(240)
                        .HasColumnType("character varying(240)");

                    b.Property<Guid?>("ProjectId")
                        .HasColumnType("uuid");

                    b.Property<string>("Prompt")
                        .IsRequired()
                        .HasColumnType("text");

                    b.Property<Guid?>("RetriedFromRunId")
                        .HasColumnType("uuid");

                    b.Property<int>("Revision")
                        .IsConcurrencyToken()
                        .HasColumnType("integer");

                    b.Property<bool>("SequenceGapDetected")
                        .HasColumnType("boolean");

                    b.Property<string>("SessionKey")
                        .IsRequired()
                        .HasMaxLength(500)
                        .HasColumnType("character varying(500)");

                    b.Property<string>("StartIdempotencyKey")
                        .IsRequired()
                        .HasMaxLength(200)
                        .HasColumnType("character varying(200)");

                    b.Property<DateTimeOffset?>("StartedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("Status")
                        .IsRequired()
                        .HasMaxLength(40)
                        .HasColumnType("character varying(40)");

                    b.Property<Guid?>("TaskId")
                        .HasColumnType("uuid");

                    b.Property<string>("Title")
                        .IsRequired()
                        .HasMaxLength(160)
                        .HasColumnType("character varying(160)");

                    b.Property<string>("TraceParent")
                        .HasMaxLength(128)
                        .HasColumnType("character varying(128)");

                    b.Property<DateTimeOffset>("UpdatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.HasKey("Id");

                    b.HasIndex("OpenClawRunId")
                        .IsUnique();

                    b.HasIndex("ProjectId");

                    b.HasIndex("RetriedFromRunId");

                    b.HasIndex("SessionKey");

                    b.HasIndex("StartIdempotencyKey")
                        .IsUnique();

                    b.HasIndex("TaskId");

                    b.HasIndex("Status", "UpdatedAt");

                    b.ToTable("OpenClawRuns");
                });

            modelBuilder.Entity("Nexus.Api.Data.OpenClawRunHistory", b =>
                {
                    b.Property<long>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("bigint");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));

                    b.Property<string>("Action")
                        .IsRequired()
                        .HasMaxLength(80)
                        .HasColumnType("character varying(80)");

                    b.Property<string>("Actor")
                        .IsRequired()
                        .HasMaxLength(240)
                        .HasColumnType("character varying(240)");

                    b.Property<string>("CorrelationId")
                        .IsRequired()
                        .HasMaxLength(200)
                        .HasColumnType("character varying(200)");

                    b.Property<string>("FromStatus")
                        .IsRequired()
                        .HasMaxLength(40)
                        .HasColumnType("character varying(40)");

                    b.Property<string>("GatewayEventId")
                        .HasMaxLength(120)
                        .HasColumnType("character varying(120)");

                    b.Property<long?>("GatewaySequence")
                        .HasColumnType("bigint");

                    b.Property<string>("IdempotencyKey")
                        .HasMaxLength(200)
                        .HasColumnType("character varying(200)");

                    b.Property<string>("Message")
                        .IsRequired()
                        .HasMaxLength(2000)
                        .HasColumnType("character varying(2000)");

                    b.Property<DateTimeOffset>("OccurredAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<Guid?>("ResultRunId")
                        .HasColumnType("uuid");

                    b.Property<Guid>("RunId")
                        .HasColumnType("uuid");

                    b.Property<bool>("SequenceGapDetected")
                        .HasColumnType("boolean");

                    b.Property<string>("ToStatus")
                        .IsRequired()
                        .HasMaxLength(40)
                        .HasColumnType("character varying(40)");

                    b.Property<string>("TraceParent")
                        .HasMaxLength(128)
                        .HasColumnType("character varying(128)");

                    b.HasKey("Id");

                    b.HasIndex("GatewayEventId")
                        .IsUnique();

                    b.HasIndex("RunId", "OccurredAt");

                    b.HasIndex("RunId", "Action", "IdempotencyKey")
                        .IsUnique();

                    b.ToTable("OpenClawRunHistory");
                });

            modelBuilder.Entity("Nexus.Api.Data.Project", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<string>("Description")
                        .IsRequired()
                        .HasColumnType("text");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(160)
                        .HasColumnType("character varying(160)");

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

                    b.Property<int>("Status")
                        .HasColumnType("integer");

                    b.Property<DateTimeOffset>("UpdatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.HasKey("Id");

                    b.ToTable("Projects");
                });

            modelBuilder.Entity("Nexus.Api.Data.RefreshToken", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<Guid>("ConcurrencyStamp")
                        .IsConcurrencyToken()
                        .HasColumnType("uuid");

                    b.Property<DateTimeOffset>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<DateTimeOffset>("ExpiresAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<Guid>("FamilyId")
                        .HasColumnType("uuid");

                    b.Property<string>("ReplacedByTokenHash")
                        .HasMaxLength(64)
                        .HasColumnType("character varying(64)");

                    b.Property<DateTimeOffset?>("RevokedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("TokenHash")
                        .IsRequired()
                        .HasMaxLength(64)
                        .HasColumnType("character varying(64)");

                    b.Property<Guid>("UserId")
                        .HasColumnType("uuid");

                    b.HasKey("Id");

                    b.HasIndex("TokenHash")
                        .IsUnique();

                    b.HasIndex("UserId", "FamilyId");

                    b.ToTable("RefreshTokens");
                });

            modelBuilder.Entity("Nexus.Api.Data.SeedAudit", b =>
                {
                    b.Property<string>("Key")
                        .HasMaxLength(80)
                        .HasColumnType("character varying(80)");

                    b.Property<DateTimeOffset>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.HasKey("Key");

                    b.ToTable("SeedAudit");
                });

            modelBuilder.Entity("Nexus.Api.Data.WorkTask", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<string>("AssignedTo")
                        .HasMaxLength(60)
                        .HasColumnType("character varying(60)");

                    b.Property<DateTimeOffset>("CreatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("Detail")
                        .HasMaxLength(2000)
                        .HasColumnType("character varying(2000)");

                    b.Property<DateTimeOffset?>("DueDate")
                        .HasColumnType("timestamp with time zone");

                    b.Property<string>("ExpectedFrom")
                        .HasMaxLength(60)
                        .HasColumnType("character varying(60)");

                    b.Property<bool>("IsAgentTask")
                        .HasColumnType("boolean");

                    b.Property<Guid?>("ParentTaskId")
                        .HasColumnType("uuid");

                    b.Property<string>("Priority")
                        .IsRequired()
                        .HasColumnType("text");

                    b.Property<Guid?>("ProjectId")
                        .HasColumnType("uuid");

                    b.Property<string>("Source")
                        .IsRequired()
                        .HasMaxLength(60)
                        .HasColumnType("character varying(60)");

                    b.Property<string>("State")
                        .IsRequired()
                        .HasColumnType("text");

                    b.Property<string>("Title")
                        .IsRequired()
                        .HasMaxLength(240)
                        .HasColumnType("character varying(240)");

                    b.Property<DateTimeOffset>("UpdatedAt")
                        .HasColumnType("timestamp with time zone");

                    b.HasKey("Id");

                    b.HasIndex("AssignedTo");

                    b.HasIndex("ExpectedFrom");

                    b.HasIndex("IsAgentTask");

                    b.HasIndex("ParentTaskId");

                    b.HasIndex("Source");

                    b.ToTable("Tasks");
                });

            modelBuilder.Entity("Nexus.Api.Data.OpenClawRun", b =>
                {
                    b.HasOne("Nexus.Api.Data.Project", null)
                        .WithMany()
                        .HasForeignKey("ProjectId")
                        .OnDelete(DeleteBehavior.SetNull);

                    b.HasOne("Nexus.Api.Data.WorkTask", null)
                        .WithMany()
                        .HasForeignKey("TaskId")
                        .OnDelete(DeleteBehavior.SetNull);
                });

            modelBuilder.Entity("Nexus.Api.Data.OpenClawRunHistory", b =>
                {
                    b.HasOne("Nexus.Api.Data.OpenClawRun", "Run")
                        .WithMany("History")
                        .HasForeignKey("RunId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Run");
                });

            modelBuilder.Entity("Nexus.Api.Data.RefreshToken", b =>
                {
                    b.HasOne("Nexus.Api.Data.NexusUser", "User")
                        .WithMany("RefreshTokens")
                        .HasForeignKey("UserId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("User");
                });

            modelBuilder.Entity("Nexus.Api.Data.WorkTask", b =>
                {
                    b.HasOne("Nexus.Api.Data.WorkTask", "ParentTask")
                        .WithMany("ChildTasks")
                        .HasForeignKey("ParentTaskId")
                        .OnDelete(DeleteBehavior.SetNull);

                    b.Navigation("ParentTask");
                });

            modelBuilder.Entity("Nexus.Api.Data.NexusUser", b =>
                {
                    b.Navigation("RefreshTokens");
                });

            modelBuilder.Entity("Nexus.Api.Data.OpenClawRun", b =>
                {
                    b.Navigation("History");
                });

            modelBuilder.Entity("Nexus.Api.Data.WorkTask", b =>
                {
                    b.Navigation("ChildTasks");
                });
#pragma warning restore 612, 618
        }
    }
}
