PIbd-22. Stroev V.M. Lab Work 05 #5

Closed
StroevVladimir wants to merge 4 commits from Lab5 into Lab4
2 changed files with 375 additions and 375 deletions
Showing only changes of commit de7aa0ebf9 - Show all commits

View File

@ -1,218 +1,218 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using PlumbingRepairDataBaseImplement; using PlumbingRepairDataBaseImplement;
#nullable disable #nullable disable
namespace PlumbingRepairDataBaseImplement.Migrations namespace PlumbingRepairDataBaseImplement.Migrations
{ {
[DbContext(typeof(PlumbingRepairDataBase))] [DbContext(typeof(PlumbingRepairDataBase))]
[Migration("20240419125319_MigrationWithClient")] [Migration("20240424045110_MigrationWithClient")]
partial class MigrationWithClient partial class MigrationWithClient
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "7.0.17") .HasAnnotation("ProductVersion", "7.0.17")
.HasAnnotation("Relational:MaxIdentifierLength", 63); .HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Client", b => modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Client", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClientFIO") b.Property<string>("ClientFIO")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("Email") b.Property<string>("Email")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("Password") b.Property<string>("Password")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Clients"); b.ToTable("Clients");
}); });
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Component", b => modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Component", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName") b.Property<string>("ComponentName")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.Property<double>("Cost") b.Property<double>("Cost")
.HasColumnType("double precision"); .HasColumnType("double precision");
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Components"); b.ToTable("Components");
}); });
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Order", b => modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Order", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ClientId") b.Property<int>("ClientId")
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<int>("Count") b.Property<int>("Count")
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<DateTime>("DateCreate") b.Property<DateTime>("DateCreate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp with time zone");
b.Property<DateTime?>("DateImplement") b.Property<DateTime?>("DateImplement")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp with time zone");
b.Property<int>("Status") b.Property<int>("Status")
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<double>("Sum") b.Property<double>("Sum")
.HasColumnType("double precision"); .HasColumnType("double precision");
b.Property<int>("WorkId") b.Property<int>("WorkId")
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<string>("WorkName") b.Property<string>("WorkName")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ClientId"); b.HasIndex("ClientId");
b.HasIndex("WorkId"); b.HasIndex("WorkId");
b.ToTable("Orders"); b.ToTable("Orders");
}); });
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Work", b => modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Work", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<double>("Price") b.Property<double>("Price")
.HasColumnType("double precision"); .HasColumnType("double precision");
b.Property<string>("WorkName") b.Property<string>("WorkName")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Works"); b.ToTable("Works");
}); });
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.WorkComponent", b => modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.WorkComponent", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId") b.Property<int>("ComponentId")
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<int>("Count") b.Property<int>("Count")
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<int>("WorkId") b.Property<int>("WorkId")
.HasColumnType("integer"); .HasColumnType("integer");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ComponentId"); b.HasIndex("ComponentId");
b.HasIndex("WorkId"); b.HasIndex("WorkId");
b.ToTable("WorkComponents"); b.ToTable("WorkComponents");
}); });
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Order", b => modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Order", b =>
{ {
b.HasOne("PlumbingRepairDataBaseImplement.Models.Client", "Client") b.HasOne("PlumbingRepairDataBaseImplement.Models.Client", "Client")
.WithMany("Orders") .WithMany("Orders")
.HasForeignKey("ClientId") .HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("PlumbingRepairDataBaseImplement.Models.Work", "Work") b.HasOne("PlumbingRepairDataBaseImplement.Models.Work", "Work")
.WithMany("Orders") .WithMany("Orders")
.HasForeignKey("WorkId") .HasForeignKey("WorkId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Client"); b.Navigation("Client");
b.Navigation("Work"); b.Navigation("Work");
}); });
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.WorkComponent", b => modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.WorkComponent", b =>
{ {
b.HasOne("PlumbingRepairDataBaseImplement.Models.Component", "Component") b.HasOne("PlumbingRepairDataBaseImplement.Models.Component", "Component")
.WithMany("WorkComponents") .WithMany("WorkComponents")
.HasForeignKey("ComponentId") .HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("PlumbingRepairDataBaseImplement.Models.Work", "Work") b.HasOne("PlumbingRepairDataBaseImplement.Models.Work", "Work")
.WithMany("Components") .WithMany("Components")
.HasForeignKey("WorkId") .HasForeignKey("WorkId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Component"); b.Navigation("Component");
b.Navigation("Work"); b.Navigation("Work");
}); });
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Client", b => modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Client", b =>
{ {
b.Navigation("Orders"); b.Navigation("Orders");
}); });
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Component", b => modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Component", b =>
{ {
b.Navigation("WorkComponents"); b.Navigation("WorkComponents");
}); });
modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Work", b => modelBuilder.Entity("PlumbingRepairDataBaseImplement.Models.Work", b =>
{ {
b.Navigation("Components"); b.Navigation("Components");
b.Navigation("Orders"); b.Navigation("Orders");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }
} }

View File

@ -1,157 +1,157 @@
using System; using System;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable
namespace PlumbingRepairDataBaseImplement.Migrations namespace PlumbingRepairDataBaseImplement.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class MigrationWithClient : Migration public partial class MigrationWithClient : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Clients", name: "Clients",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "integer", nullable: false) Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClientFIO = table.Column<string>(type: "text", nullable: false), ClientFIO = table.Column<string>(type: "text", nullable: false),
Email = table.Column<string>(type: "text", nullable: false), Email = table.Column<string>(type: "text", nullable: false),
Password = table.Column<string>(type: "text", nullable: false) Password = table.Column<string>(type: "text", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Clients", x => x.Id); table.PrimaryKey("PK_Clients", x => x.Id);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Components", name: "Components",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "integer", nullable: false) Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ComponentName = table.Column<string>(type: "text", nullable: false), ComponentName = table.Column<string>(type: "text", nullable: false),
Cost = table.Column<double>(type: "double precision", nullable: false) Cost = table.Column<double>(type: "double precision", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Components", x => x.Id); table.PrimaryKey("PK_Components", x => x.Id);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Works", name: "Works",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "integer", nullable: false) Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
WorkName = table.Column<string>(type: "text", nullable: false), WorkName = table.Column<string>(type: "text", nullable: false),
Price = table.Column<double>(type: "double precision", nullable: false) Price = table.Column<double>(type: "double precision", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Works", x => x.Id); table.PrimaryKey("PK_Works", x => x.Id);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Orders", name: "Orders",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "integer", nullable: false) Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
WorkId = table.Column<int>(type: "integer", nullable: false), WorkId = table.Column<int>(type: "integer", nullable: false),
ClientId = table.Column<int>(type: "integer", nullable: false), ClientId = table.Column<int>(type: "integer", nullable: false),
WorkName = table.Column<string>(type: "text", nullable: false), WorkName = table.Column<string>(type: "text", nullable: false),
Count = table.Column<int>(type: "integer", nullable: false), Count = table.Column<int>(type: "integer", nullable: false),
Sum = table.Column<double>(type: "double precision", nullable: false), Sum = table.Column<double>(type: "double precision", nullable: false),
Status = table.Column<int>(type: "integer", nullable: false), Status = table.Column<int>(type: "integer", nullable: false),
DateCreate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), DateCreate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateImplement = table.Column<DateTime>(type: "timestamp with time zone", nullable: true) DateImplement = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Orders", x => x.Id); table.PrimaryKey("PK_Orders", x => x.Id);
table.ForeignKey( table.ForeignKey(
name: "FK_Orders_Clients_ClientId", name: "FK_Orders_Clients_ClientId",
column: x => x.ClientId, column: x => x.ClientId,
principalTable: "Clients", principalTable: "Clients",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
table.ForeignKey( table.ForeignKey(
name: "FK_Orders_Works_WorkId", name: "FK_Orders_Works_WorkId",
column: x => x.WorkId, column: x => x.WorkId,
principalTable: "Works", principalTable: "Works",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "WorkComponents", name: "WorkComponents",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "integer", nullable: false) Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
WorkId = table.Column<int>(type: "integer", nullable: false), WorkId = table.Column<int>(type: "integer", nullable: false),
ComponentId = table.Column<int>(type: "integer", nullable: false), ComponentId = table.Column<int>(type: "integer", nullable: false),
Count = table.Column<int>(type: "integer", nullable: false) Count = table.Column<int>(type: "integer", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_WorkComponents", x => x.Id); table.PrimaryKey("PK_WorkComponents", x => x.Id);
table.ForeignKey( table.ForeignKey(
name: "FK_WorkComponents_Components_ComponentId", name: "FK_WorkComponents_Components_ComponentId",
column: x => x.ComponentId, column: x => x.ComponentId,
principalTable: "Components", principalTable: "Components",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
table.ForeignKey( table.ForeignKey(
name: "FK_WorkComponents_Works_WorkId", name: "FK_WorkComponents_Works_WorkId",
column: x => x.WorkId, column: x => x.WorkId,
principalTable: "Works", principalTable: "Works",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Orders_ClientId", name: "IX_Orders_ClientId",
table: "Orders", table: "Orders",
column: "ClientId"); column: "ClientId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Orders_WorkId", name: "IX_Orders_WorkId",
table: "Orders", table: "Orders",
column: "WorkId"); column: "WorkId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_WorkComponents_ComponentId", name: "IX_WorkComponents_ComponentId",
table: "WorkComponents", table: "WorkComponents",
column: "ComponentId"); column: "ComponentId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_WorkComponents_WorkId", name: "IX_WorkComponents_WorkId",
table: "WorkComponents", table: "WorkComponents",
column: "WorkId"); column: "WorkId");
} }
/// <inheritdoc /> /// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Orders"); name: "Orders");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "WorkComponents"); name: "WorkComponents");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Clients"); name: "Clients");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Components"); name: "Components");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Works"); name: "Works");
} }
} }
} }