//
using System;
using System.Text.Json;
using Codex.Dal;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Codex.Dal.Migrations
{
[DbContext(typeof(CodexDbContext))]
partial class CodexDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Codex.Dal.Entities.Agent", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property("ApiKeyEncrypted")
.HasColumnType("text");
b.Property("ConversationWindowSize")
.HasColumnType("integer");
b.Property("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property("Description")
.IsRequired()
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property("EnableMemory")
.HasColumnType("boolean");
b.Property("IsDeleted")
.HasColumnType("boolean");
b.Property("MaxTokens")
.HasColumnType("integer");
b.Property("ModelEndpoint")
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property("ModelName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property("ModelProvider")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property("ProviderType")
.HasColumnType("integer");
b.Property("Status")
.HasColumnType("integer");
b.Property("SystemPrompt")
.IsRequired()
.HasColumnType("text");
b.Property("Temperature")
.HasColumnType("double precision");
b.Property("Type")
.HasColumnType("integer");
b.Property("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Type");
b.HasIndex("Status", "IsDeleted");
b.ToTable("Agents");
});
modelBuilder.Entity("Codex.Dal.Entities.AgentExecution", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property("AgentId")
.HasColumnType("uuid");
b.Property("CompletedAt")
.HasColumnType("timestamp with time zone");
b.Property("ConversationId")
.HasColumnType("uuid");
b.Property("ErrorMessage")
.HasColumnType("text");
b.Property("EstimatedCost")
.HasPrecision(18, 6)
.HasColumnType("numeric(18,6)");
b.Property("ExecutionTimeMs")
.HasColumnType("bigint");
b.Property("Input")
.HasColumnType("text");
b.Property("InputTokens")
.HasColumnType("integer");
b.Property("Output")
.IsRequired()
.ValueGeneratedOnAdd()
.HasColumnType("text")
.HasDefaultValue("");
b.Property("OutputTokens")
.HasColumnType("integer");
b.Property("StartedAt")
.HasColumnType("timestamp with time zone");
b.Property("Status")
.HasColumnType("integer");
b.Property("ToolCallResults")
.HasColumnType("text");
b.Property("ToolCalls")
.HasColumnType("text");
b.Property("TotalTokens")
.HasColumnType("integer");
b.Property("UserPrompt")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ConversationId");
b.HasIndex("Status");
b.HasIndex("AgentId", "StartedAt")
.IsDescending(false, true);
b.ToTable("AgentExecutions");
});
modelBuilder.Entity("Codex.Dal.Entities.AgentTool", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property("AgentId")
.HasColumnType("uuid");
b.Property("ApiBaseUrl")
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property("ApiKeyEncrypted")
.HasColumnType("text");
b.Property("Configuration")
.HasColumnType("jsonb");
b.Property("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property("IsEnabled")
.HasColumnType("boolean");
b.Property("McpAuthTokenEncrypted")
.HasColumnType("text");
b.Property("McpServerUrl")
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property("ToolName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property("Type")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("Type");
b.HasIndex("AgentId", "IsEnabled");
b.ToTable("AgentTools");
});
modelBuilder.Entity("Codex.Dal.Entities.Conversation", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property("IsActive")
.HasColumnType("boolean");
b.Property("LastMessageAt")
.HasColumnType("timestamp with time zone");
b.Property("MessageCount")
.HasColumnType("integer");
b.Property("StartedAt")
.HasColumnType("timestamp with time zone");
b.Property("Summary")
.HasMaxLength(2000)
.HasColumnType("character varying(2000)");
b.Property("Title")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.HasKey("Id");
b.HasIndex("IsActive", "LastMessageAt")
.IsDescending(false, true);
b.ToTable("Conversations");
});
modelBuilder.Entity("Codex.Dal.Entities.ConversationMessage", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property("Content")
.IsRequired()
.HasColumnType("text");
b.Property("ConversationId")
.HasColumnType("uuid");
b.Property("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property("ExecutionId")
.HasColumnType("uuid");
b.Property("IsInActiveWindow")
.HasColumnType("boolean");
b.Property("MessageIndex")
.HasColumnType("integer");
b.Property("Role")
.HasColumnType("integer");
b.Property("TokenCount")
.HasColumnType("integer");
b.Property("ToolCalls")
.HasColumnType("text");
b.Property("ToolResults")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ExecutionId");
b.HasIndex("Role");
b.HasIndex("ConversationId", "MessageIndex");
b.HasIndex("ConversationId", "IsInActiveWindow", "MessageIndex");
b.ToTable("ConversationMessages");
});
modelBuilder.Entity("Codex.Dal.Entities.AgentExecution", b =>
{
b.HasOne("Codex.Dal.Entities.Agent", "Agent")
.WithMany("Executions")
.HasForeignKey("AgentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Codex.Dal.Entities.Conversation", "Conversation")
.WithMany("Executions")
.HasForeignKey("ConversationId")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("Agent");
b.Navigation("Conversation");
});
modelBuilder.Entity("Codex.Dal.Entities.AgentTool", b =>
{
b.HasOne("Codex.Dal.Entities.Agent", "Agent")
.WithMany("Tools")
.HasForeignKey("AgentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Agent");
});
modelBuilder.Entity("Codex.Dal.Entities.ConversationMessage", b =>
{
b.HasOne("Codex.Dal.Entities.Conversation", "Conversation")
.WithMany("Messages")
.HasForeignKey("ConversationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Codex.Dal.Entities.AgentExecution", "Execution")
.WithMany("Messages")
.HasForeignKey("ExecutionId")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("Conversation");
b.Navigation("Execution");
});
modelBuilder.Entity("Codex.Dal.Entities.Agent", b =>
{
b.Navigation("Executions");
b.Navigation("Tools");
});
modelBuilder.Entity("Codex.Dal.Entities.AgentExecution", b =>
{
b.Navigation("Messages");
});
modelBuilder.Entity("Codex.Dal.Entities.Conversation", b =>
{
b.Navigation("Executions");
b.Navigation("Messages");
});
#pragma warning restore 612, 618
}
}
}