// <auto-generated />
using System;
using ColaFlow.Modules.Mcp.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

#nullable disable

namespace ColaFlow.Modules.Mcp.Infrastructure.Persistence.Migrations
{
    [DbContext(typeof(McpDbContext))]
    [Migration("20251108173654_AddMcpApiKeys")]
    partial class AddMcpApiKeys
    {
        /// <inheritdoc />
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
#pragma warning disable 612, 618
            modelBuilder
                .HasDefaultSchema("mcp")
                .HasAnnotation("ProductVersion", "9.0.10")
                .HasAnnotation("Relational:MaxIdentifierLength", 63);

            NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);

            modelBuilder.Entity("ColaFlow.Modules.Mcp.Domain.Entities.McpApiKey", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<DateTime>("CreatedAt")
                        .HasColumnType("timestamp with time zone")
                        .HasColumnName("created_at");

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

                    b.Property<DateTime>("ExpiresAt")
                        .HasColumnType("timestamp with time zone")
                        .HasColumnName("expires_at");

                    b.Property<string>("IpWhitelist")
                        .HasColumnType("jsonb")
                        .HasColumnName("ip_whitelist");

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

                    b.Property<string>("KeyPrefix")
                        .IsRequired()
                        .HasMaxLength(16)
                        .HasColumnType("character varying(16)")
                        .HasColumnName("key_prefix");

                    b.Property<DateTime?>("LastUsedAt")
                        .HasColumnType("timestamp with time zone")
                        .HasColumnName("last_used_at");

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

                    b.Property<string>("Permissions")
                        .IsRequired()
                        .HasColumnType("jsonb")
                        .HasColumnName("permissions");

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

                    b.Property<Guid?>("RevokedBy")
                        .HasColumnType("uuid")
                        .HasColumnName("revoked_by");

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

                    b.Property<Guid>("TenantId")
                        .HasColumnType("uuid")
                        .HasColumnName("tenant_id");

                    b.Property<long>("UsageCount")
                        .HasColumnType("bigint")
                        .HasColumnName("usage_count");

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

                    b.HasKey("Id");

                    b.HasIndex("ExpiresAt")
                        .HasDatabaseName("ix_mcp_api_keys_expires_at");

                    b.HasIndex("KeyPrefix")
                        .IsUnique()
                        .HasDatabaseName("ix_mcp_api_keys_key_prefix");

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

                    b.HasIndex("TenantId")
                        .HasDatabaseName("ix_mcp_api_keys_tenant_id");

                    b.HasIndex("TenantId", "UserId")
                        .HasDatabaseName("ix_mcp_api_keys_tenant_user");

                    b.ToTable("mcp_api_keys", "mcp");
                });
#pragma warning restore 612, 618
        }
    }
}
