From 915758fdf00cdcbd1fcc90d7569734f238d1c6db Mon Sep 17 00:00:00 2001 From: Oleg Shabunov Date: Tue, 16 Apr 2024 20:11:17 +0400 Subject: [PATCH] update Migration --- ...> 20240416160914_Implementers.Designer.cs} | 47 ++++++++++++++++++- ...ents.cs => 20240416160914_Implementers.cs} | 32 ++++++++++++- .../AutoWorkshopDatabaseModelSnapshot.cs | 43 +++++++++++++++++ 3 files changed, 119 insertions(+), 3 deletions(-) rename AutoWorkshopDatabaseImplement/Migrations/{20240411091839_Clients.Designer.cs => 20240416160914_Implementers.Designer.cs} (82%) rename AutoWorkshopDatabaseImplement/Migrations/{20240411091839_Clients.cs => 20240416160914_Implementers.cs} (81%) diff --git a/AutoWorkshopDatabaseImplement/Migrations/20240411091839_Clients.Designer.cs b/AutoWorkshopDatabaseImplement/Migrations/20240416160914_Implementers.Designer.cs similarity index 82% rename from AutoWorkshopDatabaseImplement/Migrations/20240411091839_Clients.Designer.cs rename to AutoWorkshopDatabaseImplement/Migrations/20240416160914_Implementers.Designer.cs index 61a3eaf..5e9800b 100644 --- a/AutoWorkshopDatabaseImplement/Migrations/20240411091839_Clients.Designer.cs +++ b/AutoWorkshopDatabaseImplement/Migrations/20240416160914_Implementers.Designer.cs @@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace AutoWorkshopDatabaseImplement.Migrations { [DbContext(typeof(AutoWorkshopDatabase))] - [Migration("20240411091839_Clients")] - partial class Clients + [Migration("20240416160914_Implementers")] + partial class Implementers { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -70,6 +70,33 @@ namespace AutoWorkshopDatabaseImplement.Migrations b.ToTable("Components"); }); + modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.Property("Qualification") + .HasColumnType("integer"); + + b.Property("WorkExperience") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Order", b => { b.Property("Id") @@ -90,6 +117,9 @@ namespace AutoWorkshopDatabaseImplement.Migrations b.Property("DateImplement") .HasColumnType("timestamp without time zone"); + b.Property("ImplementerId") + .HasColumnType("integer"); + b.Property("RepairId") .HasColumnType("integer"); @@ -103,6 +133,8 @@ namespace AutoWorkshopDatabaseImplement.Migrations b.HasIndex("ClientId"); + b.HasIndex("ImplementerId"); + b.HasIndex("RepairId"); b.ToTable("Orders"); @@ -162,6 +194,10 @@ namespace AutoWorkshopDatabaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("AutoWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Order") + .HasForeignKey("ImplementerId"); + b.HasOne("AutoWorkshopDatabaseImplement.Models.Repair", "Repair") .WithMany("Orders") .HasForeignKey("RepairId") @@ -170,6 +206,8 @@ namespace AutoWorkshopDatabaseImplement.Migrations b.Navigation("Client"); + b.Navigation("Implementer"); + b.Navigation("Repair"); }); @@ -202,6 +240,11 @@ namespace AutoWorkshopDatabaseImplement.Migrations b.Navigation("RepairComponents"); }); + modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Order"); + }); + modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Repair", b => { b.Navigation("Components"); diff --git a/AutoWorkshopDatabaseImplement/Migrations/20240411091839_Clients.cs b/AutoWorkshopDatabaseImplement/Migrations/20240416160914_Implementers.cs similarity index 81% rename from AutoWorkshopDatabaseImplement/Migrations/20240411091839_Clients.cs rename to AutoWorkshopDatabaseImplement/Migrations/20240416160914_Implementers.cs index c1ef402..5968997 100644 --- a/AutoWorkshopDatabaseImplement/Migrations/20240411091839_Clients.cs +++ b/AutoWorkshopDatabaseImplement/Migrations/20240416160914_Implementers.cs @@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace AutoWorkshopDatabaseImplement.Migrations { /// - public partial class Clients : Migration + public partial class Implementers : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -41,6 +41,22 @@ namespace AutoWorkshopDatabaseImplement.Migrations table.PrimaryKey("PK_Components", x => x.Id); }); + migrationBuilder.CreateTable( + name: "Implementers", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ImplementerFIO = table.Column(type: "text", nullable: false), + Password = table.Column(type: "text", nullable: false), + WorkExperience = table.Column(type: "integer", nullable: false), + Qualification = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Implementers", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Repairs", columns: table => new @@ -63,6 +79,7 @@ namespace AutoWorkshopDatabaseImplement.Migrations .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), RepairId = table.Column(type: "integer", nullable: false), ClientId = table.Column(type: "integer", nullable: false), + ImplementerId = table.Column(type: "integer", nullable: true), Count = table.Column(type: "integer", nullable: false), Sum = table.Column(type: "double precision", nullable: false), Status = table.Column(type: "integer", nullable: false), @@ -78,6 +95,11 @@ namespace AutoWorkshopDatabaseImplement.Migrations principalTable: "Clients", principalColumn: "Id", onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + column: x => x.ImplementerId, + principalTable: "Implementers", + principalColumn: "Id"); table.ForeignKey( name: "FK_Orders_Repairs_RepairId", column: x => x.RepairId, @@ -118,6 +140,11 @@ namespace AutoWorkshopDatabaseImplement.Migrations table: "Orders", column: "ClientId"); + migrationBuilder.CreateIndex( + name: "IX_Orders_ImplementerId", + table: "Orders", + column: "ImplementerId"); + migrationBuilder.CreateIndex( name: "IX_Orders_RepairId", table: "Orders", @@ -146,6 +173,9 @@ namespace AutoWorkshopDatabaseImplement.Migrations migrationBuilder.DropTable( name: "Clients"); + migrationBuilder.DropTable( + name: "Implementers"); + migrationBuilder.DropTable( name: "Components"); diff --git a/AutoWorkshopDatabaseImplement/Migrations/AutoWorkshopDatabaseModelSnapshot.cs b/AutoWorkshopDatabaseImplement/Migrations/AutoWorkshopDatabaseModelSnapshot.cs index c4adfe7..8d079d4 100644 --- a/AutoWorkshopDatabaseImplement/Migrations/AutoWorkshopDatabaseModelSnapshot.cs +++ b/AutoWorkshopDatabaseImplement/Migrations/AutoWorkshopDatabaseModelSnapshot.cs @@ -67,6 +67,33 @@ namespace AutoWorkshopDatabaseImplement.Migrations b.ToTable("Components"); }); + modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.Property("Qualification") + .HasColumnType("integer"); + + b.Property("WorkExperience") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Order", b => { b.Property("Id") @@ -87,6 +114,9 @@ namespace AutoWorkshopDatabaseImplement.Migrations b.Property("DateImplement") .HasColumnType("timestamp without time zone"); + b.Property("ImplementerId") + .HasColumnType("integer"); + b.Property("RepairId") .HasColumnType("integer"); @@ -100,6 +130,8 @@ namespace AutoWorkshopDatabaseImplement.Migrations b.HasIndex("ClientId"); + b.HasIndex("ImplementerId"); + b.HasIndex("RepairId"); b.ToTable("Orders"); @@ -159,6 +191,10 @@ namespace AutoWorkshopDatabaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("AutoWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Order") + .HasForeignKey("ImplementerId"); + b.HasOne("AutoWorkshopDatabaseImplement.Models.Repair", "Repair") .WithMany("Orders") .HasForeignKey("RepairId") @@ -167,6 +203,8 @@ namespace AutoWorkshopDatabaseImplement.Migrations b.Navigation("Client"); + b.Navigation("Implementer"); + b.Navigation("Repair"); }); @@ -199,6 +237,11 @@ namespace AutoWorkshopDatabaseImplement.Migrations b.Navigation("RepairComponents"); }); + modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Order"); + }); + modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Repair", b => { b.Navigation("Components");