diff --git a/VeterinaryClinic/VeterinaryClinicDatabaseImplement/Migrations/20240430193057_InitialCreate.Designer.cs b/VeterinaryClinic/VeterinaryClinicDatabaseImplement/Migrations/20240430193057_InitialCreate.Designer.cs new file mode 100644 index 0000000..a8b78d4 --- /dev/null +++ b/VeterinaryClinic/VeterinaryClinicDatabaseImplement/Migrations/20240430193057_InitialCreate.Designer.cs @@ -0,0 +1,382 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using VeterinaryClinicDatabaseImplement; + +#nullable disable + +namespace VeterinaryClinicDatabaseImplement.Migrations +{ + [DbContext(typeof(VeterinaryClinicDatabase))] + [Migration("20240430193057_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Animal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Age") + .HasColumnType("integer"); + + b.Property("Breed") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Animals"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.AnimalMedication", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AnimalId") + .HasColumnType("integer"); + + b.Property("MedicationId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AnimalId"); + + b.HasIndex("MedicationId"); + + b.ToTable("AnimalMedications"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Medication", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Medications"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Service", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("integer"); + + b.Property("MedicationId") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("MedicationId"); + + b.ToTable("Services"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FullName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.Property("Phone") + .IsRequired() + .HasColumnType("text"); + + b.Property("Role") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Vaccination", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AnimalId") + .HasColumnType("integer"); + + b.Property("DateInjection") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.Property("ValidityPeriod") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("AnimalId"); + + b.HasIndex("UserId"); + + b.ToTable("Vaccinations"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Visit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Date") + .HasColumnType("timestamp without time zone"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Visits"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.VisitAnimal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AnimalId") + .HasColumnType("integer"); + + b.Property("VisitId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AnimalId"); + + b.HasIndex("VisitId"); + + b.ToTable("VisitAnimals"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.VisitService", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ServiceId") + .HasColumnType("integer"); + + b.Property("VisitId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ServiceId"); + + b.HasIndex("VisitId"); + + b.ToTable("VisitServices"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Animal", b => + { + b.HasOne("VeterinaryClinicDatabaseImplement.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.AnimalMedication", b => + { + b.HasOne("VeterinaryClinicDatabaseImplement.Models.Animal", "Animal") + .WithMany("Medications") + .HasForeignKey("AnimalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VeterinaryClinicDatabaseImplement.Models.Medication", "Medication") + .WithMany() + .HasForeignKey("MedicationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Animal"); + + b.Navigation("Medication"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Service", b => + { + b.HasOne("VeterinaryClinicDatabaseImplement.Models.Medication", "Medication") + .WithMany() + .HasForeignKey("MedicationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Medication"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Vaccination", b => + { + b.HasOne("VeterinaryClinicDatabaseImplement.Models.Animal", "Animal") + .WithMany() + .HasForeignKey("AnimalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VeterinaryClinicDatabaseImplement.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Animal"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Visit", b => + { + b.HasOne("VeterinaryClinicDatabaseImplement.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.VisitAnimal", b => + { + b.HasOne("VeterinaryClinicDatabaseImplement.Models.Animal", "Animal") + .WithMany() + .HasForeignKey("AnimalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VeterinaryClinicDatabaseImplement.Models.Visit", "Visit") + .WithMany("Animals") + .HasForeignKey("VisitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Animal"); + + b.Navigation("Visit"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.VisitService", b => + { + b.HasOne("VeterinaryClinicDatabaseImplement.Models.Service", "Service") + .WithMany() + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VeterinaryClinicDatabaseImplement.Models.Visit", "Visit") + .WithMany("Services") + .HasForeignKey("VisitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Service"); + + b.Navigation("Visit"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Animal", b => + { + b.Navigation("Medications"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Visit", b => + { + b.Navigation("Animals"); + + b.Navigation("Services"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/VeterinaryClinic/VeterinaryClinicDatabaseImplement/Migrations/20240430193057_InitialCreate.cs b/VeterinaryClinic/VeterinaryClinicDatabaseImplement/Migrations/20240430193057_InitialCreate.cs new file mode 100644 index 0000000..a6a5e72 --- /dev/null +++ b/VeterinaryClinic/VeterinaryClinicDatabaseImplement/Migrations/20240430193057_InitialCreate.cs @@ -0,0 +1,303 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace VeterinaryClinicDatabaseImplement.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Medications", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Medications", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + FullName = table.Column(type: "text", nullable: false), + Phone = table.Column(type: "text", nullable: false), + Email = table.Column(type: "text", nullable: false), + Password = table.Column(type: "text", nullable: false), + Role = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Services", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + Cost = table.Column(type: "integer", nullable: false), + MedicationId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Services", x => x.Id); + table.ForeignKey( + name: "FK_Services_Medications_MedicationId", + column: x => x.MedicationId, + principalTable: "Medications", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Animals", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Type = table.Column(type: "text", nullable: false), + Breed = table.Column(type: "text", nullable: false), + Age = table.Column(type: "integer", nullable: false), + UserId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Animals", x => x.Id); + table.ForeignKey( + name: "FK_Animals_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Visits", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Date = table.Column(type: "timestamp without time zone", nullable: false), + UserId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Visits", x => x.Id); + table.ForeignKey( + name: "FK_Visits_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AnimalMedications", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + AnimalId = table.Column(type: "integer", nullable: false), + MedicationId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AnimalMedications", x => x.Id); + table.ForeignKey( + name: "FK_AnimalMedications_Animals_AnimalId", + column: x => x.AnimalId, + principalTable: "Animals", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AnimalMedications_Medications_MedicationId", + column: x => x.MedicationId, + principalTable: "Medications", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Vaccinations", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + DateInjection = table.Column(type: "timestamp without time zone", nullable: false), + ValidityPeriod = table.Column(type: "text", nullable: false), + UserId = table.Column(type: "integer", nullable: false), + AnimalId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Vaccinations", x => x.Id); + table.ForeignKey( + name: "FK_Vaccinations_Animals_AnimalId", + column: x => x.AnimalId, + principalTable: "Animals", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Vaccinations_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "VisitAnimals", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + VisitId = table.Column(type: "integer", nullable: false), + AnimalId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_VisitAnimals", x => x.Id); + table.ForeignKey( + name: "FK_VisitAnimals_Animals_AnimalId", + column: x => x.AnimalId, + principalTable: "Animals", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_VisitAnimals_Visits_VisitId", + column: x => x.VisitId, + principalTable: "Visits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "VisitServices", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + VisitId = table.Column(type: "integer", nullable: false), + ServiceId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_VisitServices", x => x.Id); + table.ForeignKey( + name: "FK_VisitServices_Services_ServiceId", + column: x => x.ServiceId, + principalTable: "Services", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_VisitServices_Visits_VisitId", + column: x => x.VisitId, + principalTable: "Visits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AnimalMedications_AnimalId", + table: "AnimalMedications", + column: "AnimalId"); + + migrationBuilder.CreateIndex( + name: "IX_AnimalMedications_MedicationId", + table: "AnimalMedications", + column: "MedicationId"); + + migrationBuilder.CreateIndex( + name: "IX_Animals_UserId", + table: "Animals", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Services_MedicationId", + table: "Services", + column: "MedicationId"); + + migrationBuilder.CreateIndex( + name: "IX_Vaccinations_AnimalId", + table: "Vaccinations", + column: "AnimalId"); + + migrationBuilder.CreateIndex( + name: "IX_Vaccinations_UserId", + table: "Vaccinations", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_VisitAnimals_AnimalId", + table: "VisitAnimals", + column: "AnimalId"); + + migrationBuilder.CreateIndex( + name: "IX_VisitAnimals_VisitId", + table: "VisitAnimals", + column: "VisitId"); + + migrationBuilder.CreateIndex( + name: "IX_Visits_UserId", + table: "Visits", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_VisitServices_ServiceId", + table: "VisitServices", + column: "ServiceId"); + + migrationBuilder.CreateIndex( + name: "IX_VisitServices_VisitId", + table: "VisitServices", + column: "VisitId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AnimalMedications"); + + migrationBuilder.DropTable( + name: "Vaccinations"); + + migrationBuilder.DropTable( + name: "VisitAnimals"); + + migrationBuilder.DropTable( + name: "VisitServices"); + + migrationBuilder.DropTable( + name: "Animals"); + + migrationBuilder.DropTable( + name: "Services"); + + migrationBuilder.DropTable( + name: "Visits"); + + migrationBuilder.DropTable( + name: "Medications"); + + migrationBuilder.DropTable( + name: "Users"); + } + } +} diff --git a/VeterinaryClinic/VeterinaryClinicDatabaseImplement/Migrations/VeterinaryClinicDatabaseModelSnapshot.cs b/VeterinaryClinic/VeterinaryClinicDatabaseImplement/Migrations/VeterinaryClinicDatabaseModelSnapshot.cs new file mode 100644 index 0000000..40081fc --- /dev/null +++ b/VeterinaryClinic/VeterinaryClinicDatabaseImplement/Migrations/VeterinaryClinicDatabaseModelSnapshot.cs @@ -0,0 +1,379 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using VeterinaryClinicDatabaseImplement; + +#nullable disable + +namespace VeterinaryClinicDatabaseImplement.Migrations +{ + [DbContext(typeof(VeterinaryClinicDatabase))] + partial class VeterinaryClinicDatabaseModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Animal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Age") + .HasColumnType("integer"); + + b.Property("Breed") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Animals"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.AnimalMedication", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AnimalId") + .HasColumnType("integer"); + + b.Property("MedicationId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AnimalId"); + + b.HasIndex("MedicationId"); + + b.ToTable("AnimalMedications"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Medication", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Medications"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Service", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("integer"); + + b.Property("MedicationId") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("MedicationId"); + + b.ToTable("Services"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FullName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.Property("Phone") + .IsRequired() + .HasColumnType("text"); + + b.Property("Role") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Vaccination", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AnimalId") + .HasColumnType("integer"); + + b.Property("DateInjection") + .HasColumnType("timestamp without time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.Property("ValidityPeriod") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("AnimalId"); + + b.HasIndex("UserId"); + + b.ToTable("Vaccinations"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Visit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Date") + .HasColumnType("timestamp without time zone"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Visits"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.VisitAnimal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AnimalId") + .HasColumnType("integer"); + + b.Property("VisitId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AnimalId"); + + b.HasIndex("VisitId"); + + b.ToTable("VisitAnimals"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.VisitService", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ServiceId") + .HasColumnType("integer"); + + b.Property("VisitId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ServiceId"); + + b.HasIndex("VisitId"); + + b.ToTable("VisitServices"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Animal", b => + { + b.HasOne("VeterinaryClinicDatabaseImplement.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.AnimalMedication", b => + { + b.HasOne("VeterinaryClinicDatabaseImplement.Models.Animal", "Animal") + .WithMany("Medications") + .HasForeignKey("AnimalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VeterinaryClinicDatabaseImplement.Models.Medication", "Medication") + .WithMany() + .HasForeignKey("MedicationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Animal"); + + b.Navigation("Medication"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Service", b => + { + b.HasOne("VeterinaryClinicDatabaseImplement.Models.Medication", "Medication") + .WithMany() + .HasForeignKey("MedicationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Medication"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Vaccination", b => + { + b.HasOne("VeterinaryClinicDatabaseImplement.Models.Animal", "Animal") + .WithMany() + .HasForeignKey("AnimalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VeterinaryClinicDatabaseImplement.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Animal"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Visit", b => + { + b.HasOne("VeterinaryClinicDatabaseImplement.Models.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.VisitAnimal", b => + { + b.HasOne("VeterinaryClinicDatabaseImplement.Models.Animal", "Animal") + .WithMany() + .HasForeignKey("AnimalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VeterinaryClinicDatabaseImplement.Models.Visit", "Visit") + .WithMany("Animals") + .HasForeignKey("VisitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Animal"); + + b.Navigation("Visit"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.VisitService", b => + { + b.HasOne("VeterinaryClinicDatabaseImplement.Models.Service", "Service") + .WithMany() + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VeterinaryClinicDatabaseImplement.Models.Visit", "Visit") + .WithMany("Services") + .HasForeignKey("VisitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Service"); + + b.Navigation("Visit"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Animal", b => + { + b.Navigation("Medications"); + }); + + modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Visit", b => + { + b.Navigation("Animals"); + + b.Navigation("Services"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/VeterinaryClinic/VeterinaryClinicDatabaseImplement/Models/Visit.cs b/VeterinaryClinic/VeterinaryClinicDatabaseImplement/Models/Visit.cs index d58c839..c165f9b 100644 --- a/VeterinaryClinic/VeterinaryClinicDatabaseImplement/Models/Visit.cs +++ b/VeterinaryClinic/VeterinaryClinicDatabaseImplement/Models/Visit.cs @@ -23,7 +23,7 @@ namespace VeterinaryClinicDatabaseImplement.Models public virtual User User { get; set; } = new(); - [ForeignKey("AnimalId")] + [ForeignKey("VisitId")] public virtual List Animals { get; set; } = new(); private Dictionary? _visitAnimals = null; @@ -40,7 +40,7 @@ namespace VeterinaryClinicDatabaseImplement.Models } } - [ForeignKey("ServiceId")] + [ForeignKey("VisitId")] public virtual List Services { get; set; } = new(); private Dictionary? _visitServices = null; diff --git a/VeterinaryClinic/VeterinaryClinicWebApp/VeterinaryClinicWebApp.csproj b/VeterinaryClinic/VeterinaryClinicWebApp/VeterinaryClinicWebApp.csproj index 1b28a01..c4b4a9c 100644 --- a/VeterinaryClinic/VeterinaryClinicWebApp/VeterinaryClinicWebApp.csproj +++ b/VeterinaryClinic/VeterinaryClinicWebApp/VeterinaryClinicWebApp.csproj @@ -6,4 +6,17 @@ enable + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + +