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

#nullable disable

namespace CaseAccountingDataBaseImplement.Migrations
{
    [DbContext(typeof(CaseAccountingDatabase))]
    [Migration("20230518222251_MergMig")]
    partial class MergMig
    {
        /// <inheritdoc />
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
#pragma warning disable 612, 618
            modelBuilder
                .HasAnnotation("ProductVersion", "7.0.5")
                .HasAnnotation("Relational:MaxIdentifierLength", 63);

            NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);

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

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

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

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

                    b.Property<DateTime>("Date")
                        .HasColumnType("timestamp with time zone");

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

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

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

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

                    b.HasKey("Id");

                    b.HasIndex("SpecializationId");

                    b.HasIndex("UserId");

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

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

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

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

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

                    b.HasKey("Id");

                    b.HasIndex("CaseId");

                    b.HasIndex("DealId");

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

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

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

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

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

                    b.HasKey("Id");

                    b.HasIndex("CaseId");

                    b.HasIndex("LawyerId");

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

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

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

                    b.Property<decimal>("Coast")
                        .HasColumnType("numeric");

                    b.Property<DateTime>("Date")
                        .HasColumnType("timestamp with time zone");

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

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

                    b.HasKey("Id");

                    b.HasIndex("UserId");

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

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

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

                    b.Property<DateTime>("Date")
                        .HasColumnType("timestamp with time zone");

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

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

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

                    b.HasKey("Id");

                    b.HasIndex("UserId");

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

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

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

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

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

                    b.HasKey("Id");

                    b.HasIndex("ContractId");

                    b.HasIndex("DealId");

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

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

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

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

                    b.Property<DateTime>("Date")
                        .HasColumnType("timestamp with time zone");

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

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

                    b.HasKey("Id");

                    b.HasIndex("CaseId");

                    b.HasIndex("UserId");

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

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

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

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

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

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

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

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

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

                    b.HasKey("Id");

                    b.HasIndex("SpecializationId");

                    b.HasIndex("UserId");

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

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

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

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

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

                    b.HasKey("Id");

                    b.HasIndex("ContractId");

                    b.HasIndex("LawyerId");

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

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

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

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

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

                    b.HasKey("Id");

                    b.HasIndex("UserId");

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

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

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

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

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

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

                    b.HasKey("Id");

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

            modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
                {
                    b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization")
                        .WithMany("Cases")
                        .HasForeignKey("SpecializationId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
                        .WithMany("Cases")
                        .HasForeignKey("UserId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Specialization");

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

            modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b =>
                {
                    b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
                        .WithMany("Deals")
                        .HasForeignKey("CaseId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal")
                        .WithMany("CaseDeals")
                        .HasForeignKey("DealId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Case");

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

            modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b =>
                {
                    b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
                        .WithMany("CaseLawyers")
                        .HasForeignKey("CaseId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer")
                        .WithMany("CaseLawyers")
                        .HasForeignKey("LawyerId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Case");

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

            modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
                {
                    b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
                        .WithMany("Contracts")
                        .HasForeignKey("UserId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

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

            modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
                {
                    b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
                        .WithMany("Deals")
                        .HasForeignKey("UserId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

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

            modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b =>
                {
                    b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract")
                        .WithMany("DealContracts")
                        .HasForeignKey("ContractId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal")
                        .WithMany("Contracts")
                        .HasForeignKey("DealId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Contract");

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

            modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b =>
                {
                    b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
                        .WithMany("Hearings")
                        .HasForeignKey("CaseId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
                        .WithMany("Hearings")
                        .HasForeignKey("UserId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Case");

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

            modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
                {
                    b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization")
                        .WithMany("Lawyers")
                        .HasForeignKey("SpecializationId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
                        .WithMany("Lawyers")
                        .HasForeignKey("UserId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Specialization");

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

            modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b =>
                {
                    b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract")
                        .WithMany("LawyerContracts")
                        .HasForeignKey("ContractId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer")
                        .WithMany("LawyerContracts")
                        .HasForeignKey("LawyerId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Contract");

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

            modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
                {
                    b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
                        .WithMany("Specializations")
                        .HasForeignKey("UserId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

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

            modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
                {
                    b.Navigation("CaseLawyers");

                    b.Navigation("Deals");

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

            modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
                {
                    b.Navigation("DealContracts");

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

            modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
                {
                    b.Navigation("CaseDeals");

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

            modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
                {
                    b.Navigation("CaseLawyers");

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

            modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
                {
                    b.Navigation("Cases");

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

            modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b =>
                {
                    b.Navigation("Cases");

                    b.Navigation("Contracts");

                    b.Navigation("Deals");

                    b.Navigation("Hearings");

                    b.Navigation("Lawyers");

                    b.Navigation("Specializations");
                });
#pragma warning restore 612, 618
        }
    }
}
