diff --git a/PersonnelDepartment/PersonnelDepartmentDatabaseImplement/Migrations/20240519212229_InitialCommit.Designer.cs b/PersonnelDepartment/PersonnelDepartmentDatabaseImplement/Migrations/20240519212229_InitialCommit.Designer.cs new file mode 100644 index 0000000..e8b408d --- /dev/null +++ b/PersonnelDepartment/PersonnelDepartmentDatabaseImplement/Migrations/20240519212229_InitialCommit.Designer.cs @@ -0,0 +1,183 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using PersonnelDepartmentDatabaseImplement; + +#nullable disable + +namespace PersonnelDepartmentDatabaseImplement.Migrations +{ + [DbContext(typeof(PersonnelDepartmentDatabase))] + [Migration("20240519212229_InitialCommit")] + partial class InitialCommit + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Deal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateFrom") + .HasColumnType("timestamp with time zone"); + + b.Property("DateTo") + .HasColumnType("timestamp with time zone"); + + b.Property("DepartmentId") + .HasColumnType("integer"); + + b.Property("EmployeeId") + .HasColumnType("integer"); + + b.Property("PositionId") + .HasColumnType("integer"); + + b.Property("TypeId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("DepartmentId"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("PositionId"); + + b.HasIndex("TypeId"); + + b.ToTable("Deals"); + }); + + modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Department", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Telephone") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("Departments"); + }); + + modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Employee", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Patronymic") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Employees"); + }); + + modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Position", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Positions"); + }); + + modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Type", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Types"); + }); + + modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Deal", b => + { + b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Department", "Department") + .WithMany() + .HasForeignKey("DepartmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Employee", "Employee") + .WithMany() + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Position", "Position") + .WithMany() + .HasForeignKey("PositionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Type", "Type") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Department"); + + b.Navigation("Employee"); + + b.Navigation("Position"); + + b.Navigation("Type"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/PersonnelDepartment/PersonnelDepartmentDatabaseImplement/Migrations/20240519212229_InitialCommit.cs b/PersonnelDepartment/PersonnelDepartmentDatabaseImplement/Migrations/20240519212229_InitialCommit.cs new file mode 100644 index 0000000..b79876c --- /dev/null +++ b/PersonnelDepartment/PersonnelDepartmentDatabaseImplement/Migrations/20240519212229_InitialCommit.cs @@ -0,0 +1,152 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace PersonnelDepartmentDatabaseImplement.Migrations +{ + /// + public partial class InitialCommit : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Departments", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + Telephone = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Departments", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Employees", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + FirstName = table.Column(type: "text", nullable: false), + LastName = table.Column(type: "text", nullable: false), + Patronymic = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Employees", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Positions", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Positions", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Types", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Types", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Deals", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DateFrom = table.Column(type: "timestamp with time zone", nullable: false), + DateTo = table.Column(type: "timestamp with time zone", nullable: false), + PositionId = table.Column(type: "integer", nullable: false), + EmployeeId = table.Column(type: "integer", nullable: false), + DepartmentId = table.Column(type: "integer", nullable: false), + TypeId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Deals", x => x.Id); + table.ForeignKey( + name: "FK_Deals_Departments_DepartmentId", + column: x => x.DepartmentId, + principalTable: "Departments", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Deals_Employees_EmployeeId", + column: x => x.EmployeeId, + principalTable: "Employees", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Deals_Positions_PositionId", + column: x => x.PositionId, + principalTable: "Positions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Deals_Types_TypeId", + column: x => x.TypeId, + principalTable: "Types", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Deals_DepartmentId", + table: "Deals", + column: "DepartmentId"); + + migrationBuilder.CreateIndex( + name: "IX_Deals_EmployeeId", + table: "Deals", + column: "EmployeeId"); + + migrationBuilder.CreateIndex( + name: "IX_Deals_PositionId", + table: "Deals", + column: "PositionId"); + + migrationBuilder.CreateIndex( + name: "IX_Deals_TypeId", + table: "Deals", + column: "TypeId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Deals"); + + migrationBuilder.DropTable( + name: "Departments"); + + migrationBuilder.DropTable( + name: "Employees"); + + migrationBuilder.DropTable( + name: "Positions"); + + migrationBuilder.DropTable( + name: "Types"); + } + } +} diff --git a/PersonnelDepartment/PersonnelDepartmentDatabaseImplement/Migrations/PersonnelDepartmentDatabaseModelSnapshot.cs b/PersonnelDepartment/PersonnelDepartmentDatabaseImplement/Migrations/PersonnelDepartmentDatabaseModelSnapshot.cs new file mode 100644 index 0000000..9f25827 --- /dev/null +++ b/PersonnelDepartment/PersonnelDepartmentDatabaseImplement/Migrations/PersonnelDepartmentDatabaseModelSnapshot.cs @@ -0,0 +1,180 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using PersonnelDepartmentDatabaseImplement; + +#nullable disable + +namespace PersonnelDepartmentDatabaseImplement.Migrations +{ + [DbContext(typeof(PersonnelDepartmentDatabase))] + partial class PersonnelDepartmentDatabaseModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Deal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateFrom") + .HasColumnType("timestamp with time zone"); + + b.Property("DateTo") + .HasColumnType("timestamp with time zone"); + + b.Property("DepartmentId") + .HasColumnType("integer"); + + b.Property("EmployeeId") + .HasColumnType("integer"); + + b.Property("PositionId") + .HasColumnType("integer"); + + b.Property("TypeId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("DepartmentId"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("PositionId"); + + b.HasIndex("TypeId"); + + b.ToTable("Deals"); + }); + + modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Department", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Telephone") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("Departments"); + }); + + modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Employee", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Patronymic") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Employees"); + }); + + modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Position", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Positions"); + }); + + modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Type", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Types"); + }); + + modelBuilder.Entity("PersonnelDepartmentDatabaseImplement.Models.Deal", b => + { + b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Department", "Department") + .WithMany() + .HasForeignKey("DepartmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Employee", "Employee") + .WithMany() + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Position", "Position") + .WithMany() + .HasForeignKey("PositionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PersonnelDepartmentDatabaseImplement.Models.Type", "Type") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Department"); + + b.Navigation("Employee"); + + b.Navigation("Position"); + + b.Navigation("Type"); + }); +#pragma warning restore 612, 618 + } + } +}