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

#nullable disable

namespace PhoneToolMX.Models.Migrations
{
    [DbContext(typeof(PTMXContext))]
    [Migration("20231020040540_ExtensionPassword")]
    partial class ExtensionPassword
    {
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
#pragma warning disable 612, 618
            modelBuilder
                .HasAnnotation("ProductVersion", "6.0.23")
                .HasAnnotation("Relational:MaxIdentifierLength", 63);

            NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);

            modelBuilder.Entity("ExtensionPhone", b =>
                {
                    b.Property<int>("ExtensionsId")
                        .HasColumnType("integer");

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

                    b.HasKey("ExtensionsId", "PhonesId");

                    b.HasIndex("PhonesId");

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

            modelBuilder.Entity("ExtensionUser", b =>
                {
                    b.Property<int>("ExtensionsId")
                        .HasColumnType("integer");

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

                    b.HasKey("ExtensionsId", "OwnersId");

                    b.HasIndex("OwnersId");

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

            modelBuilder.Entity("PhoneToolMX.Models.CustomData", b =>
                {
                    b.Property<int?>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

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

                    b.Property<byte[]>("Data")
                        .HasColumnType("bytea");

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

                    b.Property<string>("FriendlyName")
                        .HasMaxLength(16)
                        .HasColumnType("character varying(16)");

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

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

                    b.HasKey("Id");

                    b.HasIndex("PhoneId");

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

            modelBuilder.Entity("PhoneToolMX.Models.Extension", b =>
                {
                    b.Property<int?>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

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

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

                    b.Property<int>("ExtId")
                        .ValueGeneratedOnAddOrUpdate()
                        .HasColumnType("integer")
                        .HasComputedColumnSql("\"Id\" + 1000", true);

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

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

                    b.Property<string>("Password")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("text")
                        .HasDefaultValueSql("encode(gen_random_bytes(18), 'base64')");

                    b.HasKey("Id");

                    b.HasIndex("HoldMusicId");

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

            modelBuilder.Entity("PhoneToolMX.Models.Phone", b =>
                {
                    b.Property<int?>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

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

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

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

                    b.Property<PhysicalAddress>("MacAddress")
                        .IsRequired()
                        .HasColumnType("macaddr");

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

                    b.HasKey("Id");

                    b.HasIndex("BackgroundId");

                    b.HasIndex("ModelId");

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

            modelBuilder.Entity("PhoneToolMX.Models.PhoneModel", b =>
                {
                    b.Property<int?>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

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

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

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

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

                    b.HasKey("Id");

                    b.ToTable("PhoneModels");

                    b.HasData(
                        new
                        {
                            Id = 0,
                            MaxExtensions = 6L,
                            ModelName = "Polycom VVX300/310",
                            PreVvxPolycom = false
                        });
                });

            modelBuilder.Entity("PhoneToolMX.Models.Role", b =>
                {
                    b.Property<string>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("text");

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

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

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

                    b.HasKey("Id");

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

            modelBuilder.Entity("PhoneToolMX.Models.User", b =>
                {
                    b.Property<string>("Id")
                        .HasColumnType("text");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    b.HasKey("Id");

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

            modelBuilder.Entity("PhoneUser", b =>
                {
                    b.Property<string>("OwnersId")
                        .HasColumnType("text");

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

                    b.HasKey("OwnersId", "PhonesId");

                    b.HasIndex("PhonesId");

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

            modelBuilder.Entity("ExtensionPhone", b =>
                {
                    b.HasOne("PhoneToolMX.Models.Extension", null)
                        .WithMany()
                        .HasForeignKey("ExtensionsId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("PhoneToolMX.Models.Phone", null)
                        .WithMany()
                        .HasForeignKey("PhonesId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();
                });

            modelBuilder.Entity("ExtensionUser", b =>
                {
                    b.HasOne("PhoneToolMX.Models.Extension", null)
                        .WithMany()
                        .HasForeignKey("ExtensionsId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("PhoneToolMX.Models.User", null)
                        .WithMany()
                        .HasForeignKey("OwnersId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();
                });

            modelBuilder.Entity("PhoneToolMX.Models.CustomData", b =>
                {
                    b.HasOne("PhoneToolMX.Models.Phone", null)
                        .WithMany("Ringtones")
                        .HasForeignKey("PhoneId");
                });

            modelBuilder.Entity("PhoneToolMX.Models.Extension", b =>
                {
                    b.HasOne("PhoneToolMX.Models.CustomData", "HoldMusic")
                        .WithMany()
                        .HasForeignKey("HoldMusicId");

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

            modelBuilder.Entity("PhoneToolMX.Models.Phone", b =>
                {
                    b.HasOne("PhoneToolMX.Models.CustomData", "Background")
                        .WithMany()
                        .HasForeignKey("BackgroundId");

                    b.HasOne("PhoneToolMX.Models.PhoneModel", "Model")
                        .WithMany()
                        .HasForeignKey("ModelId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Background");

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

            modelBuilder.Entity("PhoneUser", b =>
                {
                    b.HasOne("PhoneToolMX.Models.User", null)
                        .WithMany()
                        .HasForeignKey("OwnersId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("PhoneToolMX.Models.Phone", null)
                        .WithMany()
                        .HasForeignKey("PhonesId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();
                });

            modelBuilder.Entity("PhoneToolMX.Models.Phone", b =>
                {
                    b.Navigation("Ringtones");
                });
#pragma warning restore 612, 618
        }
    }
}