From 1b8b1a06f83c3143b7d491a270e7e12ae146b78d Mon Sep 17 00:00:00 2001 From: adeoneee Date: Thu, 17 Apr 2025 18:07:41 +0400 Subject: [PATCH] first migration --- .../DefaultConfigurationDatabase.cs | 13 + .../20250417140247_FirstMigration.Designer.cs | 338 ++++++++++++++++++ .../20250417140247_FirstMigration.cs | 254 +++++++++++++ .../SmallSoftwareDbContextModelSnapshot.cs | 335 +++++++++++++++++ .../SampleContextFactory.cs | 16 + .../SmallSoftwareDatabase.csproj | 4 + .../SmallSoftwareWebApi.csproj | 4 + 7 files changed, 964 insertions(+) create mode 100644 SmallSoftwareProject/SmallSoftwareDatabase/DefaultConfigurationDatabase.cs create mode 100644 SmallSoftwareProject/SmallSoftwareDatabase/Migrations/20250417140247_FirstMigration.Designer.cs create mode 100644 SmallSoftwareProject/SmallSoftwareDatabase/Migrations/20250417140247_FirstMigration.cs create mode 100644 SmallSoftwareProject/SmallSoftwareDatabase/Migrations/SmallSoftwareDbContextModelSnapshot.cs create mode 100644 SmallSoftwareProject/SmallSoftwareDatabase/SampleContextFactory.cs diff --git a/SmallSoftwareProject/SmallSoftwareDatabase/DefaultConfigurationDatabase.cs b/SmallSoftwareProject/SmallSoftwareDatabase/DefaultConfigurationDatabase.cs new file mode 100644 index 0000000..ed3c142 --- /dev/null +++ b/SmallSoftwareProject/SmallSoftwareDatabase/DefaultConfigurationDatabase.cs @@ -0,0 +1,13 @@ +using SmallSoftwareContracts.Infrastructure; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SmallSoftwareDatabase; + +class DefaultConfigurationDatabase : IConfigurationDatabase +{ + public string ConnectionString => ""; +} \ No newline at end of file diff --git a/SmallSoftwareProject/SmallSoftwareDatabase/Migrations/20250417140247_FirstMigration.Designer.cs b/SmallSoftwareProject/SmallSoftwareDatabase/Migrations/20250417140247_FirstMigration.Designer.cs new file mode 100644 index 0000000..304aef7 --- /dev/null +++ b/SmallSoftwareProject/SmallSoftwareDatabase/Migrations/20250417140247_FirstMigration.Designer.cs @@ -0,0 +1,338 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using SmallSoftwareDatabase; + +#nullable disable + +namespace SmallSoftwareDatabase.Migrations +{ + [DbContext(typeof(SmallSoftwareDbContext))] + [Migration("20250417140247_FirstMigration")] + partial class FirstMigration + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.InstallationRequest", b => + { + b.Property("RequestId") + .HasColumnType("text"); + + b.Property("SoftwareId") + .HasColumnType("text"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.HasKey("RequestId", "SoftwareId"); + + b.HasIndex("SoftwareId"); + + b.ToTable("InstallationRequests"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Manufacturer", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ManufacturerName") + .IsRequired() + .HasColumnType("text"); + + b.Property("PrevManufacturerName") + .HasColumnType("text"); + + b.Property("PrevPrevManufacturerName") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ManufacturerName") + .IsUnique(); + + b.ToTable("Manufacturers"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Post", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ChangeDate") + .HasColumnType("timestamp without time zone"); + + b.Property("IsActual") + .HasColumnType("boolean"); + + b.Property("PostId") + .IsRequired() + .HasColumnType("text"); + + b.Property("PostName") + .IsRequired() + .HasColumnType("text"); + + b.Property("PostType") + .HasColumnType("integer"); + + b.Property("Salary") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("PostId", "IsActual") + .IsUnique() + .HasFilter("\"IsActual\" = TRUE"); + + b.HasIndex("PostName", "IsActual") + .IsUnique() + .HasFilter("\"IsActual\" = TRUE"); + + b.ToTable("Posts"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Request", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsCancel") + .HasColumnType("boolean"); + + b.Property("RequestDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Sum") + .HasColumnType("double precision"); + + b.Property("WorkerId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("WorkerId"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Salary", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("SalaryDate") + .HasColumnType("timestamp without time zone"); + + b.Property("WorkerId") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkerSalary") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("WorkerId"); + + b.ToTable("Salaries"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Software", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ManufacturerId") + .IsRequired() + .HasColumnType("text"); + + b.Property("PrevPrevSoftwareName") + .HasColumnType("text"); + + b.Property("PrevSoftwareName") + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("SoftwareName") + .IsRequired() + .HasColumnType("text"); + + b.Property("SoftwareType") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ManufacturerId"); + + b.HasIndex("SoftwareName", "IsDeleted") + .IsUnique() + .HasFilter("\"IsDeleted\" = FALSE"); + + b.ToTable("Softwares"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.SoftwareHistory", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ChangeDate") + .HasColumnType("timestamp without time zone"); + + b.Property("OldPrice") + .HasColumnType("double precision"); + + b.Property("SoftwareId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("SoftwareId"); + + b.ToTable("SoftwareHistories"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Worker", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("BirthDate") + .HasColumnType("timestamp without time zone"); + + b.Property("EmploymentDate") + .HasColumnType("timestamp without time zone"); + + b.Property("FIO") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("PostId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Workers"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.InstallationRequest", b => + { + b.HasOne("SmallSoftwareDatabase.Models.Request", "Request") + .WithMany("InstallationRequests") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SmallSoftwareDatabase.Models.Software", "Software") + .WithMany("InstallationRequests") + .HasForeignKey("SoftwareId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Request"); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Request", b => + { + b.HasOne("SmallSoftwareDatabase.Models.Worker", "Worker") + .WithMany("Requests") + .HasForeignKey("WorkerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Worker"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Salary", b => + { + b.HasOne("SmallSoftwareDatabase.Models.Worker", "Worker") + .WithMany("Salaries") + .HasForeignKey("WorkerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Worker"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Software", b => + { + b.HasOne("SmallSoftwareDatabase.Models.Manufacturer", "Manufacturer") + .WithMany("Softwares") + .HasForeignKey("ManufacturerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Manufacturer"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.SoftwareHistory", b => + { + b.HasOne("SmallSoftwareDatabase.Models.Software", "Software") + .WithMany("SoftwareHistories") + .HasForeignKey("SoftwareId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Manufacturer", b => + { + b.Navigation("Softwares"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Request", b => + { + b.Navigation("InstallationRequests"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Software", b => + { + b.Navigation("InstallationRequests"); + + b.Navigation("SoftwareHistories"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Worker", b => + { + b.Navigation("Requests"); + + b.Navigation("Salaries"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/SmallSoftwareProject/SmallSoftwareDatabase/Migrations/20250417140247_FirstMigration.cs b/SmallSoftwareProject/SmallSoftwareDatabase/Migrations/20250417140247_FirstMigration.cs new file mode 100644 index 0000000..a5e347b --- /dev/null +++ b/SmallSoftwareProject/SmallSoftwareDatabase/Migrations/20250417140247_FirstMigration.cs @@ -0,0 +1,254 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace SmallSoftwareDatabase.Migrations +{ + /// + public partial class FirstMigration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Manufacturers", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + ManufacturerName = table.Column(type: "text", nullable: false), + PrevManufacturerName = table.Column(type: "text", nullable: true), + PrevPrevManufacturerName = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Manufacturers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Posts", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + PostId = table.Column(type: "text", nullable: false), + PostName = table.Column(type: "text", nullable: false), + PostType = table.Column(type: "integer", nullable: false), + Salary = table.Column(type: "double precision", nullable: false), + IsActual = table.Column(type: "boolean", nullable: false), + ChangeDate = table.Column(type: "timestamp without time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Posts", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Workers", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + FIO = table.Column(type: "text", nullable: false), + PostId = table.Column(type: "text", nullable: false), + BirthDate = table.Column(type: "timestamp without time zone", nullable: false), + EmploymentDate = table.Column(type: "timestamp without time zone", nullable: false), + IsDeleted = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Workers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Softwares", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + SoftwareName = table.Column(type: "text", nullable: false), + SoftwareType = table.Column(type: "integer", nullable: false), + ManufacturerId = table.Column(type: "text", nullable: false), + Price = table.Column(type: "double precision", nullable: false), + IsDeleted = table.Column(type: "boolean", nullable: false), + PrevSoftwareName = table.Column(type: "text", nullable: true), + PrevPrevSoftwareName = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Softwares", x => x.Id); + table.ForeignKey( + name: "FK_Softwares_Manufacturers_ManufacturerId", + column: x => x.ManufacturerId, + principalTable: "Manufacturers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Requests", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + WorkerId = table.Column(type: "text", nullable: false), + RequestDate = table.Column(type: "timestamp without time zone", nullable: false), + Email = table.Column(type: "text", nullable: false), + Sum = table.Column(type: "double precision", nullable: false), + IsCancel = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Requests", x => x.Id); + table.ForeignKey( + name: "FK_Requests_Workers_WorkerId", + column: x => x.WorkerId, + principalTable: "Workers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Salaries", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + WorkerId = table.Column(type: "text", nullable: false), + WorkerSalary = table.Column(type: "double precision", nullable: false), + SalaryDate = table.Column(type: "timestamp without time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Salaries", x => x.Id); + table.ForeignKey( + name: "FK_Salaries_Workers_WorkerId", + column: x => x.WorkerId, + principalTable: "Workers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "SoftwareHistories", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + SoftwareId = table.Column(type: "text", nullable: false), + OldPrice = table.Column(type: "double precision", nullable: false), + ChangeDate = table.Column(type: "timestamp without time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SoftwareHistories", x => x.Id); + table.ForeignKey( + name: "FK_SoftwareHistories_Softwares_SoftwareId", + column: x => x.SoftwareId, + principalTable: "Softwares", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "InstallationRequests", + columns: table => new + { + SoftwareId = table.Column(type: "text", nullable: false), + RequestId = table.Column(type: "text", nullable: false), + Count = table.Column(type: "integer", nullable: false), + Price = table.Column(type: "double precision", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_InstallationRequests", x => new { x.RequestId, x.SoftwareId }); + table.ForeignKey( + name: "FK_InstallationRequests_Requests_RequestId", + column: x => x.RequestId, + principalTable: "Requests", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_InstallationRequests_Softwares_SoftwareId", + column: x => x.SoftwareId, + principalTable: "Softwares", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_InstallationRequests_SoftwareId", + table: "InstallationRequests", + column: "SoftwareId"); + + migrationBuilder.CreateIndex( + name: "IX_Manufacturers_ManufacturerName", + table: "Manufacturers", + column: "ManufacturerName", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Posts_PostId_IsActual", + table: "Posts", + columns: new[] { "PostId", "IsActual" }, + unique: true, + filter: "\"IsActual\" = TRUE"); + + migrationBuilder.CreateIndex( + name: "IX_Posts_PostName_IsActual", + table: "Posts", + columns: new[] { "PostName", "IsActual" }, + unique: true, + filter: "\"IsActual\" = TRUE"); + + migrationBuilder.CreateIndex( + name: "IX_Requests_WorkerId", + table: "Requests", + column: "WorkerId"); + + migrationBuilder.CreateIndex( + name: "IX_Salaries_WorkerId", + table: "Salaries", + column: "WorkerId"); + + migrationBuilder.CreateIndex( + name: "IX_SoftwareHistories_SoftwareId", + table: "SoftwareHistories", + column: "SoftwareId"); + + migrationBuilder.CreateIndex( + name: "IX_Softwares_ManufacturerId", + table: "Softwares", + column: "ManufacturerId"); + + migrationBuilder.CreateIndex( + name: "IX_Softwares_SoftwareName_IsDeleted", + table: "Softwares", + columns: new[] { "SoftwareName", "IsDeleted" }, + unique: true, + filter: "\"IsDeleted\" = FALSE"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "InstallationRequests"); + + migrationBuilder.DropTable( + name: "Posts"); + + migrationBuilder.DropTable( + name: "Salaries"); + + migrationBuilder.DropTable( + name: "SoftwareHistories"); + + migrationBuilder.DropTable( + name: "Requests"); + + migrationBuilder.DropTable( + name: "Softwares"); + + migrationBuilder.DropTable( + name: "Workers"); + + migrationBuilder.DropTable( + name: "Manufacturers"); + } + } +} diff --git a/SmallSoftwareProject/SmallSoftwareDatabase/Migrations/SmallSoftwareDbContextModelSnapshot.cs b/SmallSoftwareProject/SmallSoftwareDatabase/Migrations/SmallSoftwareDbContextModelSnapshot.cs new file mode 100644 index 0000000..50fbfa7 --- /dev/null +++ b/SmallSoftwareProject/SmallSoftwareDatabase/Migrations/SmallSoftwareDbContextModelSnapshot.cs @@ -0,0 +1,335 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using SmallSoftwareDatabase; + +#nullable disable + +namespace SmallSoftwareDatabase.Migrations +{ + [DbContext(typeof(SmallSoftwareDbContext))] + partial class SmallSoftwareDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.InstallationRequest", b => + { + b.Property("RequestId") + .HasColumnType("text"); + + b.Property("SoftwareId") + .HasColumnType("text"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.HasKey("RequestId", "SoftwareId"); + + b.HasIndex("SoftwareId"); + + b.ToTable("InstallationRequests"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Manufacturer", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ManufacturerName") + .IsRequired() + .HasColumnType("text"); + + b.Property("PrevManufacturerName") + .HasColumnType("text"); + + b.Property("PrevPrevManufacturerName") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ManufacturerName") + .IsUnique(); + + b.ToTable("Manufacturers"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Post", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ChangeDate") + .HasColumnType("timestamp without time zone"); + + b.Property("IsActual") + .HasColumnType("boolean"); + + b.Property("PostId") + .IsRequired() + .HasColumnType("text"); + + b.Property("PostName") + .IsRequired() + .HasColumnType("text"); + + b.Property("PostType") + .HasColumnType("integer"); + + b.Property("Salary") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("PostId", "IsActual") + .IsUnique() + .HasFilter("\"IsActual\" = TRUE"); + + b.HasIndex("PostName", "IsActual") + .IsUnique() + .HasFilter("\"IsActual\" = TRUE"); + + b.ToTable("Posts"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Request", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsCancel") + .HasColumnType("boolean"); + + b.Property("RequestDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Sum") + .HasColumnType("double precision"); + + b.Property("WorkerId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("WorkerId"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Salary", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("SalaryDate") + .HasColumnType("timestamp without time zone"); + + b.Property("WorkerId") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkerSalary") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("WorkerId"); + + b.ToTable("Salaries"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Software", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("ManufacturerId") + .IsRequired() + .HasColumnType("text"); + + b.Property("PrevPrevSoftwareName") + .HasColumnType("text"); + + b.Property("PrevSoftwareName") + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("SoftwareName") + .IsRequired() + .HasColumnType("text"); + + b.Property("SoftwareType") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ManufacturerId"); + + b.HasIndex("SoftwareName", "IsDeleted") + .IsUnique() + .HasFilter("\"IsDeleted\" = FALSE"); + + b.ToTable("Softwares"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.SoftwareHistory", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ChangeDate") + .HasColumnType("timestamp without time zone"); + + b.Property("OldPrice") + .HasColumnType("double precision"); + + b.Property("SoftwareId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("SoftwareId"); + + b.ToTable("SoftwareHistories"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Worker", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("BirthDate") + .HasColumnType("timestamp without time zone"); + + b.Property("EmploymentDate") + .HasColumnType("timestamp without time zone"); + + b.Property("FIO") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("PostId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Workers"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.InstallationRequest", b => + { + b.HasOne("SmallSoftwareDatabase.Models.Request", "Request") + .WithMany("InstallationRequests") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SmallSoftwareDatabase.Models.Software", "Software") + .WithMany("InstallationRequests") + .HasForeignKey("SoftwareId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Request"); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Request", b => + { + b.HasOne("SmallSoftwareDatabase.Models.Worker", "Worker") + .WithMany("Requests") + .HasForeignKey("WorkerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Worker"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Salary", b => + { + b.HasOne("SmallSoftwareDatabase.Models.Worker", "Worker") + .WithMany("Salaries") + .HasForeignKey("WorkerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Worker"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Software", b => + { + b.HasOne("SmallSoftwareDatabase.Models.Manufacturer", "Manufacturer") + .WithMany("Softwares") + .HasForeignKey("ManufacturerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Manufacturer"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.SoftwareHistory", b => + { + b.HasOne("SmallSoftwareDatabase.Models.Software", "Software") + .WithMany("SoftwareHistories") + .HasForeignKey("SoftwareId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Manufacturer", b => + { + b.Navigation("Softwares"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Request", b => + { + b.Navigation("InstallationRequests"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Software", b => + { + b.Navigation("InstallationRequests"); + + b.Navigation("SoftwareHistories"); + }); + + modelBuilder.Entity("SmallSoftwareDatabase.Models.Worker", b => + { + b.Navigation("Requests"); + + b.Navigation("Salaries"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/SmallSoftwareProject/SmallSoftwareDatabase/SampleContextFactory.cs b/SmallSoftwareProject/SmallSoftwareDatabase/SampleContextFactory.cs new file mode 100644 index 0000000..148186b --- /dev/null +++ b/SmallSoftwareProject/SmallSoftwareDatabase/SampleContextFactory.cs @@ -0,0 +1,16 @@ +using Microsoft.EntityFrameworkCore.Design; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SmallSoftwareDatabase; + +internal class SampleContextFactory : IDesignTimeDbContextFactory +{ + public SmallSoftwareDbContext CreateDbContext(string[] args) + { + return new SmallSoftwareDbContext(new DefaultConfigurationDatabase()); + } +} \ No newline at end of file diff --git a/SmallSoftwareProject/SmallSoftwareDatabase/SmallSoftwareDatabase.csproj b/SmallSoftwareProject/SmallSoftwareDatabase/SmallSoftwareDatabase.csproj index 4210b78..72eb352 100644 --- a/SmallSoftwareProject/SmallSoftwareDatabase/SmallSoftwareDatabase.csproj +++ b/SmallSoftwareProject/SmallSoftwareDatabase/SmallSoftwareDatabase.csproj @@ -9,6 +9,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/SmallSoftwareProject/SmallSoftwareWebApi/SmallSoftwareWebApi.csproj b/SmallSoftwareProject/SmallSoftwareWebApi/SmallSoftwareWebApi.csproj index 34641e2..18fd74d 100644 --- a/SmallSoftwareProject/SmallSoftwareWebApi/SmallSoftwareWebApi.csproj +++ b/SmallSoftwareProject/SmallSoftwareWebApi/SmallSoftwareWebApi.csproj @@ -9,6 +9,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive +