This commit is contained in:
Николай 2023-04-01 18:15:04 +04:00
parent 0a6b99d4d0
commit 293856939f
5 changed files with 256 additions and 186 deletions

View File

@ -10,11 +10,7 @@ namespace HardwareShopDatabaseImplement
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-SINQU55\SQLEXPRESS;Initial Catalog=HardwareShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=Computer_Hardware_Store;Username=postgres;Password=1234");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)

View File

@ -8,11 +8,11 @@
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
</ItemGroup>
<ItemGroup>

View File

@ -3,16 +3,16 @@ using System;
using HardwareShopDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace HardwareShopDatabaseImplement.Migrations
{
[DbContext(typeof(HardwareShopDatabase))]
[Migration("20230401124213_init1")]
[Migration("20230401141253_init1")]
partial class init1
{
/// <inheritdoc />
@ -21,20 +21,20 @@ namespace HardwareShopDatabaseImplement.Migrations
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
.HasAnnotation("Relational:MaxIdentifierLength", 63);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.BuildComponent", b =>
{
b.Property<int>("ComponentId")
.HasColumnType("int");
.HasColumnType("integer");
b.Property<int>("BuildId")
.HasColumnType("int");
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("int");
.HasColumnType("integer");
b.HasKey("ComponentId", "BuildId");
@ -46,13 +46,13 @@ namespace HardwareShopDatabaseImplement.Migrations
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseBuild", b =>
{
b.Property<int>("PurchaseId")
.HasColumnType("int");
.HasColumnType("integer");
b.Property<int>("BuildId")
.HasColumnType("int");
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("int");
.HasColumnType("integer");
b.HasKey("PurchaseId", "BuildId");
@ -64,13 +64,13 @@ namespace HardwareShopDatabaseImplement.Migrations
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseGood", b =>
{
b.Property<int>("PurchaseId")
.HasColumnType("int");
.HasColumnType("integer");
b.Property<int>("GoodId")
.HasColumnType("int");
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("int");
.HasColumnType("integer");
b.HasKey("PurchaseId", "GoodId");
@ -83,16 +83,16 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<int>("ClientId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("ClientId");
b.ToTable("Components");
});
@ -101,16 +101,16 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<int>("ClientId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("ClientId");
b.ToTable("Goods");
});
@ -119,16 +119,16 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<int>("ClientId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("ClientId");
b.ToTable("Orders");
});
@ -137,24 +137,24 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
.HasColumnType("text");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("nvarchar(max)");
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
.HasColumnType("text");
b.Property<int>("Role")
.HasColumnType("int");
.HasColumnType("integer");
b.HasKey("Id");
@ -165,23 +165,26 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("BuildName")
.IsRequired()
.HasColumnType("nvarchar(max)");
.HasColumnType("text");
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<decimal>("Price")
.HasColumnType("decimal(18,2)");
.HasColumnType("numeric");
b.Property<int>("UserId")
.HasColumnType("int");
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("ClientId");
b.ToTable("Builds");
});
@ -190,21 +193,26 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("BuildId")
.HasColumnType("int");
.HasColumnType("integer");
b.Property<int?>("ClientId")
.HasColumnType("integer");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("nvarchar(max)");
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("BuildId");
b.HasIndex("ClientId");
b.ToTable("Comments");
});
@ -212,25 +220,28 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<DateTime?>("DatePurchase")
.HasColumnType("datetime2");
.HasColumnType("timestamp with time zone");
b.Property<int>("PurchaseStatus")
.HasColumnType("int");
.HasColumnType("integer");
b.Property<decimal>("Sum")
.HasColumnType("decimal(18,2)");
.HasColumnType("numeric");
b.Property<int>("UserId")
.HasColumnType("int");
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("ClientId");
b.ToTable("Purchases");
});
@ -295,8 +306,8 @@ namespace HardwareShopDatabaseImplement.Migrations
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.WithMany("Components")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -306,8 +317,8 @@ namespace HardwareShopDatabaseImplement.Migrations
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.WithMany("Goods")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -317,8 +328,8 @@ namespace HardwareShopDatabaseImplement.Migrations
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Order", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -328,8 +339,8 @@ namespace HardwareShopDatabaseImplement.Migrations
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.WithMany("Builds")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -344,20 +355,39 @@ namespace HardwareShopDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HardwareShopDatabaseImplement.Models.User", null)
.WithMany("Comments")
.HasForeignKey("ClientId");
b.Navigation("Build");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.WithMany("Purchases")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.User", b =>
{
b.Navigation("Builds");
b.Navigation("Comments");
b.Navigation("Components");
b.Navigation("Goods");
b.Navigation("Orders");
b.Navigation("Purchases");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
{
b.Navigation("Comments");

View File

@ -1,5 +1,6 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
@ -15,12 +16,12 @@ namespace HardwareShopDatabaseImplement.Migrations
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Login = table.Column<string>(type: "nvarchar(max)", nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
Role = table.Column<int>(type: "int", nullable: false)
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 =>
{
@ -31,18 +32,19 @@ namespace HardwareShopDatabaseImplement.Migrations
name: "Builds",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Price = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
BuildName = table.Column<string>(type: "nvarchar(max)", nullable: false),
UserId = table.Column<int>(type: "int", nullable: false)
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),
ClientId = 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,
name: "FK_Builds_Users_ClientId",
column: x => x.ClientId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
@ -52,16 +54,16 @@ namespace HardwareShopDatabaseImplement.Migrations
name: "Components",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<int>(type: "int", nullable: false)
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClientId = 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,
name: "FK_Components_Users_ClientId",
column: x => x.ClientId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
@ -71,16 +73,16 @@ namespace HardwareShopDatabaseImplement.Migrations
name: "Goods",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<int>(type: "int", nullable: false)
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClientId = 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,
name: "FK_Goods_Users_ClientId",
column: x => x.ClientId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
@ -90,16 +92,16 @@ namespace HardwareShopDatabaseImplement.Migrations
name: "Orders",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<int>(type: "int", nullable: false)
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClientId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.Id);
table.ForeignKey(
name: "FK_Orders_Users_UserId",
column: x => x.UserId,
name: "FK_Orders_Users_ClientId",
column: x => x.ClientId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
@ -109,19 +111,20 @@ namespace HardwareShopDatabaseImplement.Migrations
name: "Purchases",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Sum = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
PurchaseStatus = table.Column<int>(type: "int", nullable: false),
DatePurchase = table.Column<DateTime>(type: "datetime2", nullable: true),
UserId = table.Column<int>(type: "int", nullable: false)
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),
ClientId = 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,
name: "FK_Purchases_Users_ClientId",
column: x => x.ClientId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
@ -131,10 +134,11 @@ namespace HardwareShopDatabaseImplement.Migrations
name: "Comments",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Text = table.Column<string>(type: "nvarchar(max)", nullable: false),
BuildId = table.Column<int>(type: "int", nullable: false)
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),
ClientId = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
{
@ -145,15 +149,20 @@ namespace HardwareShopDatabaseImplement.Migrations
principalTable: "Builds",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Comments_Users_ClientId",
column: x => x.ClientId,
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "BuildsComponents",
columns: table => new
{
BuildId = table.Column<int>(type: "int", nullable: false),
ComponentId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false)
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 =>
{
@ -176,9 +185,9 @@ namespace HardwareShopDatabaseImplement.Migrations
name: "PurchasesBuilds",
columns: table => new
{
BuildId = table.Column<int>(type: "int", nullable: false),
PurchaseId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false)
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 =>
{
@ -201,9 +210,9 @@ namespace HardwareShopDatabaseImplement.Migrations
name: "PurchasesGoods",
columns: table => new
{
PurchaseId = table.Column<int>(type: "int", nullable: false),
GoodId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false)
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 =>
{
@ -223,9 +232,9 @@ namespace HardwareShopDatabaseImplement.Migrations
});
migrationBuilder.CreateIndex(
name: "IX_Builds_UserId",
name: "IX_Builds_ClientId",
table: "Builds",
column: "UserId");
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_BuildsComponents_BuildId",
@ -238,24 +247,29 @@ namespace HardwareShopDatabaseImplement.Migrations
column: "BuildId");
migrationBuilder.CreateIndex(
name: "IX_Components_UserId",
name: "IX_Comments_ClientId",
table: "Comments",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_Components_ClientId",
table: "Components",
column: "UserId");
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_Goods_UserId",
name: "IX_Goods_ClientId",
table: "Goods",
column: "UserId");
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_Orders_UserId",
name: "IX_Orders_ClientId",
table: "Orders",
column: "UserId");
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_Purchases_UserId",
name: "IX_Purchases_ClientId",
table: "Purchases",
column: "UserId");
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_PurchasesBuilds_BuildId",

View File

@ -3,8 +3,8 @@ using System;
using HardwareShopDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
@ -18,20 +18,20 @@ namespace HardwareShopDatabaseImplement.Migrations
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
.HasAnnotation("Relational:MaxIdentifierLength", 63);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.BuildComponent", b =>
{
b.Property<int>("ComponentId")
.HasColumnType("int");
.HasColumnType("integer");
b.Property<int>("BuildId")
.HasColumnType("int");
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("int");
.HasColumnType("integer");
b.HasKey("ComponentId", "BuildId");
@ -43,13 +43,13 @@ namespace HardwareShopDatabaseImplement.Migrations
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseBuild", b =>
{
b.Property<int>("PurchaseId")
.HasColumnType("int");
.HasColumnType("integer");
b.Property<int>("BuildId")
.HasColumnType("int");
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("int");
.HasColumnType("integer");
b.HasKey("PurchaseId", "BuildId");
@ -61,13 +61,13 @@ namespace HardwareShopDatabaseImplement.Migrations
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseGood", b =>
{
b.Property<int>("PurchaseId")
.HasColumnType("int");
.HasColumnType("integer");
b.Property<int>("GoodId")
.HasColumnType("int");
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("int");
.HasColumnType("integer");
b.HasKey("PurchaseId", "GoodId");
@ -80,16 +80,16 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<int>("ClientId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("ClientId");
b.ToTable("Components");
});
@ -98,16 +98,16 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<int>("ClientId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("ClientId");
b.ToTable("Goods");
});
@ -116,16 +116,16 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<int>("ClientId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("ClientId");
b.ToTable("Orders");
});
@ -134,24 +134,24 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
.HasColumnType("text");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("nvarchar(max)");
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
.HasColumnType("text");
b.Property<int>("Role")
.HasColumnType("int");
.HasColumnType("integer");
b.HasKey("Id");
@ -162,23 +162,26 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("BuildName")
.IsRequired()
.HasColumnType("nvarchar(max)");
.HasColumnType("text");
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<decimal>("Price")
.HasColumnType("decimal(18,2)");
.HasColumnType("numeric");
b.Property<int>("UserId")
.HasColumnType("int");
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("ClientId");
b.ToTable("Builds");
});
@ -187,21 +190,26 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("BuildId")
.HasColumnType("int");
.HasColumnType("integer");
b.Property<int?>("ClientId")
.HasColumnType("integer");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("nvarchar(max)");
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("BuildId");
b.HasIndex("ClientId");
b.ToTable("Comments");
});
@ -209,25 +217,28 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("integer");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<DateTime?>("DatePurchase")
.HasColumnType("datetime2");
.HasColumnType("timestamp with time zone");
b.Property<int>("PurchaseStatus")
.HasColumnType("int");
.HasColumnType("integer");
b.Property<decimal>("Sum")
.HasColumnType("decimal(18,2)");
.HasColumnType("numeric");
b.Property<int>("UserId")
.HasColumnType("int");
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("ClientId");
b.ToTable("Purchases");
});
@ -292,8 +303,8 @@ namespace HardwareShopDatabaseImplement.Migrations
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.WithMany("Components")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -303,8 +314,8 @@ namespace HardwareShopDatabaseImplement.Migrations
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.WithMany("Goods")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -314,8 +325,8 @@ namespace HardwareShopDatabaseImplement.Migrations
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Order", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -325,8 +336,8 @@ namespace HardwareShopDatabaseImplement.Migrations
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.WithMany("Builds")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -341,20 +352,39 @@ namespace HardwareShopDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HardwareShopDatabaseImplement.Models.User", null)
.WithMany("Comments")
.HasForeignKey("ClientId");
b.Navigation("Build");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
{
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.WithMany("Purchases")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.User", b =>
{
b.Navigation("Builds");
b.Navigation("Comments");
b.Navigation("Components");
b.Navigation("Goods");
b.Navigation("Orders");
b.Navigation("Purchases");
});
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
{
b.Navigation("Comments");