migration

This commit is contained in:
Sergey Kozyrev 2024-04-27 22:15:31 +04:00
parent e4533c4b03
commit 7d4a7ae995
3 changed files with 1529 additions and 0 deletions

View File

@ -0,0 +1,562 @@
// <auto-generated />
using System;
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(FactoryGoWorkDatabase))]
[Migration("20240427181429_init")]
partial class init
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.29")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.Models.Detail", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<double>("Cost")
.HasColumnType("double precision");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Details");
});
modelBuilder.Entity("DatabaseImplement.Models.DetailProduct", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<int>("DetailId")
.HasColumnType("integer");
b.Property<int>("ProductId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DetailId");
b.HasIndex("ProductId");
b.ToTable("DetailProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.DetailProduction", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("DetailId")
.HasColumnType("integer");
b.Property<int>("ProductionId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DetailId");
b.HasIndex("ProductionId");
b.ToTable("DetailProductions");
});
modelBuilder.Entity("DatabaseImplement.Models.Guarantor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Guarantors");
});
modelBuilder.Entity("DatabaseImplement.Models.Implementer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Implementers");
});
modelBuilder.Entity("DatabaseImplement.Models.Machine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Country")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Machines");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<double>("Cost")
.HasColumnType("double precision");
b.Property<int?>("MachineId")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("MachineId");
b.HasIndex("UserId");
b.ToTable("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Production", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<double>("Cost")
.HasColumnType("double precision");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Productions");
});
modelBuilder.Entity("DatabaseImplement.Models.Worker", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("Birthday")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Salary")
.HasColumnType("double precision");
b.Property<string>("Specialization")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Workers");
});
modelBuilder.Entity("DatabaseImplement.Models.WorkerMachine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("MachineId")
.HasColumnType("integer");
b.Property<int>("WorkerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("WorkerId");
b.ToTable("WorkerMachines");
});
modelBuilder.Entity("DatabaseImplement.Models.WorkerWorkshop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("WorkerId")
.HasColumnType("integer");
b.Property<int>("WorkshopId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("WorkerId");
b.HasIndex("WorkshopId");
b.ToTable("WorkerWorkshops");
});
modelBuilder.Entity("DatabaseImplement.Models.Workshop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Director")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("ProductionId")
.IsRequired()
.HasColumnType("integer");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
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()
.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("WorkerId")
.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()
.HasForeignKey("ProductionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Guarantor", "Guarantor")
.WithMany("Workshops")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Guarantor");
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("Workers");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Navigation("Details");
});
modelBuilder.Entity("DatabaseImplement.Models.Production", b =>
{
b.Navigation("Details");
});
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,407 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
public partial class init : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Guarantors",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Email = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Login = table.Column<string>(type: "text", nullable: false),
Password = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Guarantors", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Implementers",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Email = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Login = table.Column<string>(type: "text", nullable: false),
Password = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Implementers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Machines",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Title = table.Column<string>(type: "text", nullable: false),
Country = table.Column<string>(type: "text", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Machines", x => x.Id);
table.ForeignKey(
name: "FK_Machines_Guarantors_UserId",
column: x => x.UserId,
principalTable: "Guarantors",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Workers",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
Birthday = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Specialization = table.Column<string>(type: "text", nullable: false),
Salary = table.Column<double>(type: "double precision", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Workers", x => x.Id);
table.ForeignKey(
name: "FK_Workers_Guarantors_UserId",
column: x => x.UserId,
principalTable: "Guarantors",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Details",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
Cost = table.Column<double>(type: "double precision", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Details", x => x.Id);
table.ForeignKey(
name: "FK_Details_Implementers_UserId",
column: x => x.UserId,
principalTable: "Implementers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Productions",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
Cost = table.Column<double>(type: "double precision", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Productions", x => x.Id);
table.ForeignKey(
name: "FK_Productions_Implementers_UserId",
column: x => x.UserId,
principalTable: "Implementers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Products",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
Cost = table.Column<double>(type: "double precision", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false),
MachineId = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Products", x => x.Id);
table.ForeignKey(
name: "FK_Products_Implementers_UserId",
column: x => x.UserId,
principalTable: "Implementers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Products_Machines_MachineId",
column: x => x.MachineId,
principalTable: "Machines",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "WorkerMachines",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
WorkerId = table.Column<int>(type: "integer", nullable: false),
MachineId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_WorkerMachines", x => x.Id);
table.ForeignKey(
name: "FK_WorkerMachines_Machines_WorkerId",
column: x => x.WorkerId,
principalTable: "Machines",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_WorkerMachines_Workers_WorkerId",
column: x => x.WorkerId,
principalTable: "Workers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "DetailProductions",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DetailId = table.Column<int>(type: "integer", nullable: false),
ProductionId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DetailProductions", x => x.Id);
table.ForeignKey(
name: "FK_DetailProductions_Details_DetailId",
column: x => x.DetailId,
principalTable: "Details",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_DetailProductions_Productions_ProductionId",
column: x => x.ProductionId,
principalTable: "Productions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Workshops",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Title = table.Column<string>(type: "text", nullable: false),
Address = table.Column<string>(type: "text", nullable: false),
Director = table.Column<string>(type: "text", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false),
ProductionId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Workshops", x => x.Id);
table.ForeignKey(
name: "FK_Workshops_Guarantors_UserId",
column: x => x.UserId,
principalTable: "Guarantors",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Workshops_Productions_ProductionId",
column: x => x.ProductionId,
principalTable: "Productions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "DetailProducts",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DetailId = table.Column<int>(type: "integer", nullable: false),
ProductId = table.Column<int>(type: "integer", nullable: false),
Count = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DetailProducts", x => x.Id);
table.ForeignKey(
name: "FK_DetailProducts_Details_DetailId",
column: x => x.DetailId,
principalTable: "Details",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_DetailProducts_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "WorkerWorkshops",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
WorkerId = table.Column<int>(type: "integer", nullable: false),
WorkshopId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_WorkerWorkshops", x => x.Id);
table.ForeignKey(
name: "FK_WorkerWorkshops_Workers_WorkerId",
column: x => x.WorkerId,
principalTable: "Workers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_WorkerWorkshops_Workshops_WorkshopId",
column: x => x.WorkshopId,
principalTable: "Workshops",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_DetailProductions_DetailId",
table: "DetailProductions",
column: "DetailId");
migrationBuilder.CreateIndex(
name: "IX_DetailProductions_ProductionId",
table: "DetailProductions",
column: "ProductionId");
migrationBuilder.CreateIndex(
name: "IX_DetailProducts_DetailId",
table: "DetailProducts",
column: "DetailId");
migrationBuilder.CreateIndex(
name: "IX_DetailProducts_ProductId",
table: "DetailProducts",
column: "ProductId");
migrationBuilder.CreateIndex(
name: "IX_Details_UserId",
table: "Details",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Machines_UserId",
table: "Machines",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Productions_UserId",
table: "Productions",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Products_MachineId",
table: "Products",
column: "MachineId");
migrationBuilder.CreateIndex(
name: "IX_Products_UserId",
table: "Products",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_WorkerMachines_WorkerId",
table: "WorkerMachines",
column: "WorkerId");
migrationBuilder.CreateIndex(
name: "IX_Workers_UserId",
table: "Workers",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_WorkerWorkshops_WorkerId",
table: "WorkerWorkshops",
column: "WorkerId");
migrationBuilder.CreateIndex(
name: "IX_WorkerWorkshops_WorkshopId",
table: "WorkerWorkshops",
column: "WorkshopId");
migrationBuilder.CreateIndex(
name: "IX_Workshops_ProductionId",
table: "Workshops",
column: "ProductionId");
migrationBuilder.CreateIndex(
name: "IX_Workshops_UserId",
table: "Workshops",
column: "UserId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "DetailProductions");
migrationBuilder.DropTable(
name: "DetailProducts");
migrationBuilder.DropTable(
name: "WorkerMachines");
migrationBuilder.DropTable(
name: "WorkerWorkshops");
migrationBuilder.DropTable(
name: "Details");
migrationBuilder.DropTable(
name: "Products");
migrationBuilder.DropTable(
name: "Workers");
migrationBuilder.DropTable(
name: "Workshops");
migrationBuilder.DropTable(
name: "Machines");
migrationBuilder.DropTable(
name: "Productions");
migrationBuilder.DropTable(
name: "Guarantors");
migrationBuilder.DropTable(
name: "Implementers");
}
}
}

View File

@ -0,0 +1,560 @@
// <auto-generated />
using System;
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(FactoryGoWorkDatabase))]
partial class FactoryGoWorkDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.29")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.Models.Detail", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<double>("Cost")
.HasColumnType("double precision");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Details");
});
modelBuilder.Entity("DatabaseImplement.Models.DetailProduct", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<int>("DetailId")
.HasColumnType("integer");
b.Property<int>("ProductId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DetailId");
b.HasIndex("ProductId");
b.ToTable("DetailProducts");
});
modelBuilder.Entity("DatabaseImplement.Models.DetailProduction", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("DetailId")
.HasColumnType("integer");
b.Property<int>("ProductionId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DetailId");
b.HasIndex("ProductionId");
b.ToTable("DetailProductions");
});
modelBuilder.Entity("DatabaseImplement.Models.Guarantor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Guarantors");
});
modelBuilder.Entity("DatabaseImplement.Models.Implementer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Implementers");
});
modelBuilder.Entity("DatabaseImplement.Models.Machine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Country")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Machines");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<double>("Cost")
.HasColumnType("double precision");
b.Property<int?>("MachineId")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("MachineId");
b.HasIndex("UserId");
b.ToTable("Products");
});
modelBuilder.Entity("DatabaseImplement.Models.Production", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<double>("Cost")
.HasColumnType("double precision");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Productions");
});
modelBuilder.Entity("DatabaseImplement.Models.Worker", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("Birthday")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Salary")
.HasColumnType("double precision");
b.Property<string>("Specialization")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Workers");
});
modelBuilder.Entity("DatabaseImplement.Models.WorkerMachine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("MachineId")
.HasColumnType("integer");
b.Property<int>("WorkerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("WorkerId");
b.ToTable("WorkerMachines");
});
modelBuilder.Entity("DatabaseImplement.Models.WorkerWorkshop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("WorkerId")
.HasColumnType("integer");
b.Property<int>("WorkshopId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("WorkerId");
b.HasIndex("WorkshopId");
b.ToTable("WorkerWorkshops");
});
modelBuilder.Entity("DatabaseImplement.Models.Workshop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Director")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("ProductionId")
.IsRequired()
.HasColumnType("integer");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
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()
.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("WorkerId")
.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()
.HasForeignKey("ProductionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DatabaseImplement.Models.Guarantor", "Guarantor")
.WithMany("Workshops")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Guarantor");
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("Workers");
});
modelBuilder.Entity("DatabaseImplement.Models.Product", b =>
{
b.Navigation("Details");
});
modelBuilder.Entity("DatabaseImplement.Models.Production", b =>
{
b.Navigation("Details");
});
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
}
}
}