AddMigrationTime

This commit is contained in:
Sergey Kozyrev 2024-05-01 16:14:12 +04:00
parent 6887ca6b8c
commit d19f461f44
3 changed files with 656 additions and 5 deletions

View File

@ -0,0 +1,572 @@
// <auto-generated />
using System;
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(FactoryGoWorkDatabase))]
[Migration("20240501121257_addtimeforguarantor")]
partial class addtimeforguarantor
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.29")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("DatabaseImplement.Models.Detail", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<double>("Cost")
.HasColumnType("float");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Details");
});
modelBuilder.Entity("DatabaseImplement.Models.DetailProduct", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("DetailId")
.HasColumnType("int");
b.Property<int>("ProductId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("DetailId");
b.HasIndex("ProductId");
b.ToTable("DetailProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.DetailProduction", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<int>("DetailId")
.HasColumnType("int");
b.Property<int>("ProductionId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("DetailId");
b.HasIndex("ProductionId");
b.ToTable("DetailProductions");
});
modelBuilder.Entity("DatabaseImplement.Models.Guarantor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Guarantors");
});
modelBuilder.Entity("DatabaseImplement.Models.Implementer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Implementers");
});
modelBuilder.Entity("DatabaseImplement.Models.Machine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Country")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Machines");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<double>("Cost")
.HasColumnType("float");
b.Property<int?>("MachineId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("MachineId");
b.HasIndex("UserId");
b.ToTable("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Production", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<double>("Cost")
.HasColumnType("float");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Productions");
});
modelBuilder.Entity("DatabaseImplement.Models.Worker", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<DateTime>("Birthday")
.HasColumnType("datetime2");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Salary")
.HasColumnType("float");
b.Property<string>("Specialization")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Workers");
});
modelBuilder.Entity("DatabaseImplement.Models.WorkerMachine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<int>("MachineId")
.HasColumnType("int");
b.Property<int>("WorkerId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("MachineId");
b.HasIndex("WorkerId");
b.ToTable("WorkerMachines");
});
modelBuilder.Entity("DatabaseImplement.Models.WorkerWorkshop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<int>("WorkerId")
.HasColumnType("int");
b.Property<int>("WorkshopId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("WorkerId");
b.HasIndex("WorkshopId");
b.ToTable("WorkerWorkshops");
});
modelBuilder.Entity("DatabaseImplement.Models.Workshop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Address")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<string>("Director")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("ProductionId")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProductionId");
b.HasIndex("UserId");
b.ToTable("Workshops");
});
modelBuilder.Entity("DatabaseImplement.Models.Detail", b =>
{
b.HasOne("DatabaseImplement.Models.Implementer", "User")
.WithMany("Details")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("DatabaseImplement.Models.DetailProduct", b =>
{
b.HasOne("DatabaseImplement.Models.Detail", "Detail")
.WithMany("DetailProducts")
.HasForeignKey("DetailId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Product", "Product")
.WithMany("Details")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Detail");
b.Navigation("Product");
});
modelBuilder.Entity("DatabaseImplement.Models.DetailProduction", b =>
{
b.HasOne("DatabaseImplement.Models.Detail", "Detail")
.WithMany("DetailProductions")
.HasForeignKey("DetailId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Production", "Production")
.WithMany("Details")
.HasForeignKey("ProductionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Detail");
b.Navigation("Production");
});
modelBuilder.Entity("DatabaseImplement.Models.Machine", b =>
{
b.HasOne("DatabaseImplement.Models.Guarantor", "Guarantor")
.WithMany("Machines")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Guarantor");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.HasOne("DatabaseImplement.Models.Machine", "Machine")
.WithMany("Products")
.HasForeignKey("MachineId");
b.HasOne("DatabaseImplement.Models.Implementer", "User")
.WithMany("Products")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Machine");
b.Navigation("User");
});
modelBuilder.Entity("DatabaseImplement.Models.Production", b =>
{
b.HasOne("DatabaseImplement.Models.Implementer", "User")
.WithMany("Productions")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("DatabaseImplement.Models.Worker", b =>
{
b.HasOne("DatabaseImplement.Models.Guarantor", "Guarantor")
.WithMany("Workers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Guarantor");
});
modelBuilder.Entity("DatabaseImplement.Models.WorkerMachine", b =>
{
b.HasOne("DatabaseImplement.Models.Machine", "Machine")
.WithMany("Workers")
.HasForeignKey("MachineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Worker", "Worker")
.WithMany("WorkerMachines")
.HasForeignKey("WorkerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Machine");
b.Navigation("Worker");
});
modelBuilder.Entity("DatabaseImplement.Models.WorkerWorkshop", b =>
{
b.HasOne("DatabaseImplement.Models.Worker", "Worker")
.WithMany("WorkerWorkshops")
.HasForeignKey("WorkerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Workshop", "Workshop")
.WithMany("Workers")
.HasForeignKey("WorkshopId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Worker");
b.Navigation("Workshop");
});
modelBuilder.Entity("DatabaseImplement.Models.Workshop", b =>
{
b.HasOne("DatabaseImplement.Models.Production", "Production")
.WithMany("Workshops")
.HasForeignKey("ProductionId");
b.HasOne("DatabaseImplement.Models.Guarantor", null)
.WithMany("Workshops")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Production");
});
modelBuilder.Entity("DatabaseImplement.Models.Detail", b =>
{
b.Navigation("DetailProductions");
b.Navigation("DetailProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.Guarantor", b =>
{
b.Navigation("Machines");
b.Navigation("Workers");
b.Navigation("Workshops");
});
modelBuilder.Entity("DatabaseImplement.Models.Implementer", b =>
{
b.Navigation("Details");
b.Navigation("Productions");
b.Navigation("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Machine", b =>
{
b.Navigation("Products");
b.Navigation("Workers");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Navigation("Details");
});
modelBuilder.Entity("DatabaseImplement.Models.Production", b =>
{
b.Navigation("Details");
b.Navigation("Workshops");
});
modelBuilder.Entity("DatabaseImplement.Models.Worker", b =>
{
b.Navigation("WorkerMachines");
b.Navigation("WorkerWorkshops");
});
modelBuilder.Entity("DatabaseImplement.Models.Workshop", b =>
{
b.Navigation("Workers");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,71 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DatabaseImplement.Migrations
{
public partial class addtimeforguarantor : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_WorkerMachines_Machines_WorkerId",
table: "WorkerMachines");
migrationBuilder.AddColumn<DateTime>(
name: "DateCreate",
table: "Workshops",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<DateTime>(
name: "DateCreate",
table: "Machines",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.CreateIndex(
name: "IX_WorkerMachines_MachineId",
table: "WorkerMachines",
column: "MachineId");
migrationBuilder.AddForeignKey(
name: "FK_WorkerMachines_Machines_MachineId",
table: "WorkerMachines",
column: "MachineId",
principalTable: "Machines",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_WorkerMachines_Machines_MachineId",
table: "WorkerMachines");
migrationBuilder.DropIndex(
name: "IX_WorkerMachines_MachineId",
table: "WorkerMachines");
migrationBuilder.DropColumn(
name: "DateCreate",
table: "Workshops");
migrationBuilder.DropColumn(
name: "DateCreate",
table: "Machines");
migrationBuilder.AddForeignKey(
name: "FK_WorkerMachines_Machines_WorkerId",
table: "WorkerMachines",
column: "WorkerId",
principalTable: "Machines",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
}
}

View File

@ -169,6 +169,9 @@ namespace DatabaseImplement.Migrations
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<string>("Title") b.Property<string>("Title")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
@ -286,6 +289,8 @@ namespace DatabaseImplement.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("MachineId");
b.HasIndex("WorkerId"); b.HasIndex("WorkerId");
b.ToTable("WorkerMachines"); b.ToTable("WorkerMachines");
@ -326,6 +331,9 @@ namespace DatabaseImplement.Migrations
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<string>("Director") b.Property<string>("Director")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
@ -412,7 +420,7 @@ namespace DatabaseImplement.Migrations
modelBuilder.Entity("DatabaseImplement.Models.Product", b => modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{ {
b.HasOne("DatabaseImplement.Models.Machine", "Machine") b.HasOne("DatabaseImplement.Models.Machine", "Machine")
.WithMany() .WithMany("Products")
.HasForeignKey("MachineId"); .HasForeignKey("MachineId");
b.HasOne("DatabaseImplement.Models.Implementer", "User") b.HasOne("DatabaseImplement.Models.Implementer", "User")
@ -452,7 +460,7 @@ namespace DatabaseImplement.Migrations
{ {
b.HasOne("DatabaseImplement.Models.Machine", "Machine") b.HasOne("DatabaseImplement.Models.Machine", "Machine")
.WithMany("Workers") .WithMany("Workers")
.HasForeignKey("WorkerId") .HasForeignKey("MachineId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
@ -492,15 +500,13 @@ namespace DatabaseImplement.Migrations
.WithMany("Workshops") .WithMany("Workshops")
.HasForeignKey("ProductionId"); .HasForeignKey("ProductionId");
b.HasOne("DatabaseImplement.Models.Guarantor", "User") b.HasOne("DatabaseImplement.Models.Guarantor", null)
.WithMany("Workshops") .WithMany("Workshops")
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Production"); b.Navigation("Production");
b.Navigation("User");
}); });
modelBuilder.Entity("DatabaseImplement.Models.Detail", b => modelBuilder.Entity("DatabaseImplement.Models.Detail", b =>
@ -530,6 +536,8 @@ namespace DatabaseImplement.Migrations
modelBuilder.Entity("DatabaseImplement.Models.Machine", b => modelBuilder.Entity("DatabaseImplement.Models.Machine", b =>
{ {
b.Navigation("Products");
b.Navigation("Workers"); b.Navigation("Workers");
}); });