Временное сохранение

This commit is contained in:
dasha 2023-04-01 18:58:51 +04:00
parent 9a9c67388a
commit 64e2bbe928
9 changed files with 1312 additions and 1 deletions

View File

@ -6,4 +6,8 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
</ItemGroup>
</Project> </Project>

View File

@ -6,6 +6,10 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\HardwareShopDataModels\HardwareShopDataModels.csproj" /> <ProjectReference Include="..\HardwareShopDataModels\HardwareShopDataModels.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -6,4 +6,8 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
</ItemGroup>
</Project> </Project>

View File

@ -12,7 +12,7 @@ namespace HardwareShopDatabaseImplement
{ {
if (optionsBuilder.IsConfigured == false) if (optionsBuilder.IsConfigured == false)
{ {
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-D8KMQQU\SQLEXPRESS;Initial Catalog=HardwareShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); optionsBuilder.UseNpgsql("Host=192.168.0.101;Port=5432;Database=Computer_Hardware_Store;Username=user;Password=12345");
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }

View File

@ -19,6 +19,7 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -0,0 +1,470 @@
// <auto-generated />
using System;
using HardwareShopDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace HardwareShopDatabaseImplement.Migrations
{
[DbContext(typeof(HardwareShopDatabase))]
[Migration("20230401141411_InitMigration")]
partial class InitMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.BuildComponent", b =>
{
b.Property<int>("ComponentId")
.HasColumnType("integer");
b.Property<int>("BuildId")
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("integer");
b.HasKey("ComponentId", "BuildId");
b.HasIndex("BuildId");
b.ToTable("BuildsComponents");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.GoodComponent", b =>
{
b.Property<int>("GoodId")
.HasColumnType("integer");
b.Property<int>("ComponentId")
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("integer");
b.HasKey("GoodId", "ComponentId");
b.HasIndex("ComponentId");
b.ToTable("GoodComponents");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseBuild", b =>
{
b.Property<int>("PurchaseId")
.HasColumnType("integer");
b.Property<int>("BuildId")
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("integer");
b.HasKey("PurchaseId", "BuildId");
b.HasIndex("BuildId");
b.ToTable("PurchasesBuilds");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseGood", b =>
{
b.Property<int>("PurchaseId")
.HasColumnType("integer");
b.Property<int>("GoodId")
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("integer");
b.HasKey("PurchaseId", "GoodId");
b.HasIndex("GoodId");
b.ToTable("PurchasesGoods");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Cost")
.HasColumnType("double precision");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Components");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("GoodName")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Goods");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<DateTime>("DateCreate")
.HasColumnType("timestamp with time zone");
b.Property<DateTime?>("DateImplement")
.HasColumnType("timestamp with time zone");
b.Property<int>("GoodId")
.HasColumnType("integer");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<double>("Sum")
.HasColumnType("double precision");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("GoodId");
b.HasIndex("UserId");
b.ToTable("Orders");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.User", 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>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Role")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("BuildName")
.IsRequired()
.HasColumnType("text");
b.Property<decimal>("Price")
.HasColumnType("numeric");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Builds");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Comment", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("BuildId")
.HasColumnType("integer");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("BuildId");
b.ToTable("Comments");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime?>("DatePurchase")
.HasColumnType("timestamp with time zone");
b.Property<int>("PurchaseStatus")
.HasColumnType("integer");
b.Property<decimal>("Sum")
.HasColumnType("numeric");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Purchases");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.BuildComponent", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Build", "Build")
.WithMany("Components")
.HasForeignKey("BuildId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Component", "Component")
.WithMany()
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Build");
b.Navigation("Component");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.GoodComponent", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Component", "Component")
.WithMany("GoodComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Good", "Good")
.WithMany("Components")
.HasForeignKey("GoodId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Good");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseBuild", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Build", "Build")
.WithMany("Purchases")
.HasForeignKey("BuildId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Purchase", "Purchase")
.WithMany("Builds")
.HasForeignKey("PurchaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Build");
b.Navigation("Purchase");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseGood", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Good", "Good")
.WithMany()
.HasForeignKey("GoodId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Purchase", "Purchase")
.WithMany("Goods")
.HasForeignKey("PurchaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Good");
b.Navigation("Purchase");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Order", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Good", "Good")
.WithMany("Orders")
.HasForeignKey("GoodId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Good");
b.Navigation("User");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Comment", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Build", "Build")
.WithMany("Comments")
.HasForeignKey("BuildId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Build");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
{
b.Navigation("GoodComponents");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
{
b.Navigation("Comments");
b.Navigation("Components");
b.Navigation("Purchases");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
{
b.Navigation("Builds");
b.Navigation("Goods");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,360 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace HardwareShopDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Login = table.Column<string>(type: "text", nullable: false),
Email = table.Column<string>(type: "text", nullable: false),
Password = table.Column<string>(type: "text", nullable: false),
Role = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Builds",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Price = table.Column<decimal>(type: "numeric", nullable: false),
BuildName = table.Column<string>(type: "text", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Builds", x => x.Id);
table.ForeignKey(
name: "FK_Builds_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Components",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ComponentName = 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_Components", x => x.Id);
table.ForeignKey(
name: "FK_Components_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Goods",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
GoodName = table.Column<string>(type: "text", nullable: false),
Price = table.Column<double>(type: "double precision", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Goods", x => x.Id);
table.ForeignKey(
name: "FK_Goods_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Purchases",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Sum = table.Column<decimal>(type: "numeric", nullable: false),
PurchaseStatus = table.Column<int>(type: "integer", nullable: false),
DatePurchase = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
UserId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Purchases", x => x.Id);
table.ForeignKey(
name: "FK_Purchases_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Comments",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Text = table.Column<string>(type: "text", nullable: false),
BuildId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Comments", x => x.Id);
table.ForeignKey(
name: "FK_Comments_Builds_BuildId",
column: x => x.BuildId,
principalTable: "Builds",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "BuildsComponents",
columns: table => new
{
BuildId = table.Column<int>(type: "integer", nullable: false),
ComponentId = table.Column<int>(type: "integer", nullable: false),
Count = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BuildsComponents", x => new { x.ComponentId, x.BuildId });
table.ForeignKey(
name: "FK_BuildsComponents_Builds_BuildId",
column: x => x.BuildId,
principalTable: "Builds",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_BuildsComponents_Components_ComponentId",
column: x => x.ComponentId,
principalTable: "Components",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "GoodComponents",
columns: table => new
{
GoodId = table.Column<int>(type: "integer", nullable: false),
ComponentId = table.Column<int>(type: "integer", nullable: false),
Count = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GoodComponents", x => new { x.GoodId, x.ComponentId });
table.ForeignKey(
name: "FK_GoodComponents_Components_ComponentId",
column: x => x.ComponentId,
principalTable: "Components",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GoodComponents_Goods_GoodId",
column: x => x.GoodId,
principalTable: "Goods",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
GoodId = table.Column<int>(type: "integer", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false),
Count = table.Column<int>(type: "integer", nullable: false),
Sum = table.Column<double>(type: "double precision", nullable: false),
Status = table.Column<int>(type: "integer", nullable: false),
DateCreate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateImplement = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.Id);
table.ForeignKey(
name: "FK_Orders_Goods_GoodId",
column: x => x.GoodId,
principalTable: "Goods",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Orders_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "PurchasesBuilds",
columns: table => new
{
BuildId = table.Column<int>(type: "integer", nullable: false),
PurchaseId = table.Column<int>(type: "integer", nullable: false),
Count = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PurchasesBuilds", x => new { x.PurchaseId, x.BuildId });
table.ForeignKey(
name: "FK_PurchasesBuilds_Builds_BuildId",
column: x => x.BuildId,
principalTable: "Builds",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PurchasesBuilds_Purchases_PurchaseId",
column: x => x.PurchaseId,
principalTable: "Purchases",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "PurchasesGoods",
columns: table => new
{
PurchaseId = table.Column<int>(type: "integer", nullable: false),
GoodId = table.Column<int>(type: "integer", nullable: false),
Count = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PurchasesGoods", x => new { x.PurchaseId, x.GoodId });
table.ForeignKey(
name: "FK_PurchasesGoods_Goods_GoodId",
column: x => x.GoodId,
principalTable: "Goods",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PurchasesGoods_Purchases_PurchaseId",
column: x => x.PurchaseId,
principalTable: "Purchases",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Builds_UserId",
table: "Builds",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_BuildsComponents_BuildId",
table: "BuildsComponents",
column: "BuildId");
migrationBuilder.CreateIndex(
name: "IX_Comments_BuildId",
table: "Comments",
column: "BuildId");
migrationBuilder.CreateIndex(
name: "IX_Components_UserId",
table: "Components",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_GoodComponents_ComponentId",
table: "GoodComponents",
column: "ComponentId");
migrationBuilder.CreateIndex(
name: "IX_Goods_UserId",
table: "Goods",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Orders_GoodId",
table: "Orders",
column: "GoodId");
migrationBuilder.CreateIndex(
name: "IX_Orders_UserId",
table: "Orders",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Purchases_UserId",
table: "Purchases",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_PurchasesBuilds_BuildId",
table: "PurchasesBuilds",
column: "BuildId");
migrationBuilder.CreateIndex(
name: "IX_PurchasesGoods_GoodId",
table: "PurchasesGoods",
column: "GoodId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "BuildsComponents");
migrationBuilder.DropTable(
name: "Comments");
migrationBuilder.DropTable(
name: "GoodComponents");
migrationBuilder.DropTable(
name: "Orders");
migrationBuilder.DropTable(
name: "PurchasesBuilds");
migrationBuilder.DropTable(
name: "PurchasesGoods");
migrationBuilder.DropTable(
name: "Components");
migrationBuilder.DropTable(
name: "Builds");
migrationBuilder.DropTable(
name: "Goods");
migrationBuilder.DropTable(
name: "Purchases");
migrationBuilder.DropTable(
name: "Users");
}
}
}

View File

@ -0,0 +1,467 @@
// <auto-generated />
using System;
using HardwareShopDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace HardwareShopDatabaseImplement.Migrations
{
[DbContext(typeof(HardwareShopDatabase))]
partial class HardwareShopDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.BuildComponent", b =>
{
b.Property<int>("ComponentId")
.HasColumnType("integer");
b.Property<int>("BuildId")
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("integer");
b.HasKey("ComponentId", "BuildId");
b.HasIndex("BuildId");
b.ToTable("BuildsComponents");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.GoodComponent", b =>
{
b.Property<int>("GoodId")
.HasColumnType("integer");
b.Property<int>("ComponentId")
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("integer");
b.HasKey("GoodId", "ComponentId");
b.HasIndex("ComponentId");
b.ToTable("GoodComponents");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseBuild", b =>
{
b.Property<int>("PurchaseId")
.HasColumnType("integer");
b.Property<int>("BuildId")
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("integer");
b.HasKey("PurchaseId", "BuildId");
b.HasIndex("BuildId");
b.ToTable("PurchasesBuilds");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseGood", b =>
{
b.Property<int>("PurchaseId")
.HasColumnType("integer");
b.Property<int>("GoodId")
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("integer");
b.HasKey("PurchaseId", "GoodId");
b.HasIndex("GoodId");
b.ToTable("PurchasesGoods");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Cost")
.HasColumnType("double precision");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Components");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("GoodName")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Goods");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<DateTime>("DateCreate")
.HasColumnType("timestamp with time zone");
b.Property<DateTime?>("DateImplement")
.HasColumnType("timestamp with time zone");
b.Property<int>("GoodId")
.HasColumnType("integer");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<double>("Sum")
.HasColumnType("double precision");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("GoodId");
b.HasIndex("UserId");
b.ToTable("Orders");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.User", 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>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Role")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("BuildName")
.IsRequired()
.HasColumnType("text");
b.Property<decimal>("Price")
.HasColumnType("numeric");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Builds");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Comment", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("BuildId")
.HasColumnType("integer");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("BuildId");
b.ToTable("Comments");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime?>("DatePurchase")
.HasColumnType("timestamp with time zone");
b.Property<int>("PurchaseStatus")
.HasColumnType("integer");
b.Property<decimal>("Sum")
.HasColumnType("numeric");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Purchases");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.BuildComponent", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Build", "Build")
.WithMany("Components")
.HasForeignKey("BuildId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Component", "Component")
.WithMany()
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Build");
b.Navigation("Component");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.GoodComponent", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Component", "Component")
.WithMany("GoodComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Good", "Good")
.WithMany("Components")
.HasForeignKey("GoodId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Good");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseBuild", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Build", "Build")
.WithMany("Purchases")
.HasForeignKey("BuildId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Purchase", "Purchase")
.WithMany("Builds")
.HasForeignKey("PurchaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Build");
b.Navigation("Purchase");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseGood", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Good", "Good")
.WithMany()
.HasForeignKey("GoodId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Purchase", "Purchase")
.WithMany("Goods")
.HasForeignKey("PurchaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Good");
b.Navigation("Purchase");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Order", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Good", "Good")
.WithMany("Orders")
.HasForeignKey("GoodId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Good");
b.Navigation("User");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Comment", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Build", "Build")
.WithMany("Comments")
.HasForeignKey("BuildId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Build");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
{
b.Navigation("GoodComponents");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
{
b.Navigation("Comments");
b.Navigation("Components");
b.Navigation("Purchases");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
{
b.Navigation("Builds");
b.Navigation("Goods");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -13,6 +13,7 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>