diff --git a/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs b/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs
index 59867cc..fe07f33 100644
--- a/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs
+++ b/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs
@@ -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)
diff --git a/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabaseImplement.csproj b/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabaseImplement.csproj
index 352a24a..cae92b1 100644
--- a/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabaseImplement.csproj
+++ b/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabaseImplement.csproj
@@ -8,11 +8,11 @@
-
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401124213_init1.Designer.cs b/HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401141253_init1.Designer.cs
similarity index 70%
rename from HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401124213_init1.Designer.cs
rename to HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401141253_init1.Designer.cs
index 50b9050..72cc5f2 100644
--- a/HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401124213_init1.Designer.cs
+++ b/HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401141253_init1.Designer.cs
@@ -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
{
///
@@ -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("ComponentId")
- .HasColumnType("int");
+ .HasColumnType("integer");
b.Property("BuildId")
- .HasColumnType("int");
+ .HasColumnType("integer");
b.Property("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("PurchaseId")
- .HasColumnType("int");
+ .HasColumnType("integer");
b.Property("BuildId")
- .HasColumnType("int");
+ .HasColumnType("integer");
b.Property("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("PurchaseId")
- .HasColumnType("int");
+ .HasColumnType("integer");
b.Property("GoodId")
- .HasColumnType("int");
+ .HasColumnType("integer");
b.Property("Count")
- .HasColumnType("int");
+ .HasColumnType("integer");
b.HasKey("PurchaseId", "GoodId");
@@ -83,16 +83,16 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property("Id")
.ValueGeneratedOnAdd()
- .HasColumnType("int");
+ .HasColumnType("integer");
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
- b.Property("UserId")
- .HasColumnType("int");
+ b.Property("ClientId")
+ .HasColumnType("integer");
b.HasKey("Id");
- b.HasIndex("UserId");
+ b.HasIndex("ClientId");
b.ToTable("Components");
});
@@ -101,16 +101,16 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property("Id")
.ValueGeneratedOnAdd()
- .HasColumnType("int");
+ .HasColumnType("integer");
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
- b.Property("UserId")
- .HasColumnType("int");
+ b.Property("ClientId")
+ .HasColumnType("integer");
b.HasKey("Id");
- b.HasIndex("UserId");
+ b.HasIndex("ClientId");
b.ToTable("Goods");
});
@@ -119,16 +119,16 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property("Id")
.ValueGeneratedOnAdd()
- .HasColumnType("int");
+ .HasColumnType("integer");
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
- b.Property("UserId")
- .HasColumnType("int");
+ b.Property("ClientId")
+ .HasColumnType("integer");
b.HasKey("Id");
- b.HasIndex("UserId");
+ b.HasIndex("ClientId");
b.ToTable("Orders");
});
@@ -137,24 +137,24 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property("Id")
.ValueGeneratedOnAdd()
- .HasColumnType("int");
+ .HasColumnType("integer");
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("Email")
.IsRequired()
- .HasColumnType("nvarchar(max)");
+ .HasColumnType("text");
b.Property("Login")
.IsRequired()
- .HasColumnType("nvarchar(max)");
+ .HasColumnType("text");
b.Property("Password")
.IsRequired()
- .HasColumnType("nvarchar(max)");
+ .HasColumnType("text");
b.Property("Role")
- .HasColumnType("int");
+ .HasColumnType("integer");
b.HasKey("Id");
@@ -165,23 +165,26 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property("Id")
.ValueGeneratedOnAdd()
- .HasColumnType("int");
+ .HasColumnType("integer");
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("BuildName")
.IsRequired()
- .HasColumnType("nvarchar(max)");
+ .HasColumnType("text");
+
+ b.Property("ClientId")
+ .HasColumnType("integer");
b.Property("Price")
- .HasColumnType("decimal(18,2)");
+ .HasColumnType("numeric");
b.Property("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("Id")
.ValueGeneratedOnAdd()
- .HasColumnType("int");
+ .HasColumnType("integer");
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("BuildId")
- .HasColumnType("int");
+ .HasColumnType("integer");
+
+ b.Property("ClientId")
+ .HasColumnType("integer");
b.Property("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("Id")
.ValueGeneratedOnAdd()
- .HasColumnType("int");
+ .HasColumnType("integer");
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ClientId")
+ .HasColumnType("integer");
b.Property("DatePurchase")
- .HasColumnType("datetime2");
+ .HasColumnType("timestamp with time zone");
b.Property("PurchaseStatus")
- .HasColumnType("int");
+ .HasColumnType("integer");
b.Property("Sum")
- .HasColumnType("decimal(18,2)");
+ .HasColumnType("numeric");
b.Property("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");
diff --git a/HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401124213_init1.cs b/HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401141253_init1.cs
similarity index 63%
rename from HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401124213_init1.cs
rename to HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401141253_init1.cs
index d03c65f..2c92685 100644
--- a/HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401124213_init1.cs
+++ b/HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401141253_init1.cs
@@ -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(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Login = table.Column(type: "nvarchar(max)", nullable: false),
- Email = table.Column(type: "nvarchar(max)", nullable: false),
- Password = table.Column(type: "nvarchar(max)", nullable: false),
- Role = table.Column(type: "int", nullable: false)
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ Login = table.Column(type: "text", nullable: false),
+ Email = table.Column(type: "text", nullable: false),
+ Password = table.Column(type: "text", nullable: false),
+ Role = table.Column(type: "integer", nullable: false)
},
constraints: table =>
{
@@ -31,18 +32,19 @@ namespace HardwareShopDatabaseImplement.Migrations
name: "Builds",
columns: table => new
{
- Id = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Price = table.Column(type: "decimal(18,2)", nullable: false),
- BuildName = table.Column(type: "nvarchar(max)", nullable: false),
- UserId = table.Column(type: "int", nullable: false)
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ Price = table.Column(type: "numeric", nullable: false),
+ BuildName = table.Column(type: "text", nullable: false),
+ UserId = table.Column(type: "integer", nullable: false),
+ ClientId = table.Column(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(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- UserId = table.Column(type: "int", nullable: false)
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ ClientId = table.Column(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(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- UserId = table.Column(type: "int", nullable: false)
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ ClientId = table.Column(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(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- UserId = table.Column(type: "int", nullable: false)
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ ClientId = table.Column(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(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Sum = table.Column(type: "decimal(18,2)", nullable: false),
- PurchaseStatus = table.Column(type: "int", nullable: false),
- DatePurchase = table.Column(type: "datetime2", nullable: true),
- UserId = table.Column(type: "int", nullable: false)
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ Sum = table.Column(type: "numeric", nullable: false),
+ PurchaseStatus = table.Column(type: "integer", nullable: false),
+ DatePurchase = table.Column(type: "timestamp with time zone", nullable: true),
+ UserId = table.Column(type: "integer", nullable: false),
+ ClientId = table.Column(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(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Text = table.Column(type: "nvarchar(max)", nullable: false),
- BuildId = table.Column(type: "int", nullable: false)
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ Text = table.Column(type: "text", nullable: false),
+ BuildId = table.Column(type: "integer", nullable: false),
+ ClientId = table.Column(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(type: "int", nullable: false),
- ComponentId = table.Column(type: "int", nullable: false),
- Count = table.Column(type: "int", nullable: false)
+ BuildId = table.Column(type: "integer", nullable: false),
+ ComponentId = table.Column(type: "integer", nullable: false),
+ Count = table.Column(type: "integer", nullable: false)
},
constraints: table =>
{
@@ -176,9 +185,9 @@ namespace HardwareShopDatabaseImplement.Migrations
name: "PurchasesBuilds",
columns: table => new
{
- BuildId = table.Column(type: "int", nullable: false),
- PurchaseId = table.Column(type: "int", nullable: false),
- Count = table.Column(type: "int", nullable: false)
+ BuildId = table.Column(type: "integer", nullable: false),
+ PurchaseId = table.Column(type: "integer", nullable: false),
+ Count = table.Column(type: "integer", nullable: false)
},
constraints: table =>
{
@@ -201,9 +210,9 @@ namespace HardwareShopDatabaseImplement.Migrations
name: "PurchasesGoods",
columns: table => new
{
- PurchaseId = table.Column(type: "int", nullable: false),
- GoodId = table.Column(type: "int", nullable: false),
- Count = table.Column(type: "int", nullable: false)
+ PurchaseId = table.Column(type: "integer", nullable: false),
+ GoodId = table.Column(type: "integer", nullable: false),
+ Count = table.Column(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",
diff --git a/HardwareShop/HardwareShopDatabaseImplement/Migrations/HardwareShopDatabaseModelSnapshot.cs b/HardwareShop/HardwareShopDatabaseImplement/Migrations/HardwareShopDatabaseModelSnapshot.cs
index bf9e625..a4fe60b 100644
--- a/HardwareShop/HardwareShopDatabaseImplement/Migrations/HardwareShopDatabaseModelSnapshot.cs
+++ b/HardwareShop/HardwareShopDatabaseImplement/Migrations/HardwareShopDatabaseModelSnapshot.cs
@@ -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("ComponentId")
- .HasColumnType("int");
+ .HasColumnType("integer");
b.Property("BuildId")
- .HasColumnType("int");
+ .HasColumnType("integer");
b.Property("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("PurchaseId")
- .HasColumnType("int");
+ .HasColumnType("integer");
b.Property("BuildId")
- .HasColumnType("int");
+ .HasColumnType("integer");
b.Property("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("PurchaseId")
- .HasColumnType("int");
+ .HasColumnType("integer");
b.Property("GoodId")
- .HasColumnType("int");
+ .HasColumnType("integer");
b.Property("Count")
- .HasColumnType("int");
+ .HasColumnType("integer");
b.HasKey("PurchaseId", "GoodId");
@@ -80,16 +80,16 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property("Id")
.ValueGeneratedOnAdd()
- .HasColumnType("int");
+ .HasColumnType("integer");
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
- b.Property("UserId")
- .HasColumnType("int");
+ b.Property("ClientId")
+ .HasColumnType("integer");
b.HasKey("Id");
- b.HasIndex("UserId");
+ b.HasIndex("ClientId");
b.ToTable("Components");
});
@@ -98,16 +98,16 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property("Id")
.ValueGeneratedOnAdd()
- .HasColumnType("int");
+ .HasColumnType("integer");
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
- b.Property("UserId")
- .HasColumnType("int");
+ b.Property("ClientId")
+ .HasColumnType("integer");
b.HasKey("Id");
- b.HasIndex("UserId");
+ b.HasIndex("ClientId");
b.ToTable("Goods");
});
@@ -116,16 +116,16 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property("Id")
.ValueGeneratedOnAdd()
- .HasColumnType("int");
+ .HasColumnType("integer");
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
- b.Property("UserId")
- .HasColumnType("int");
+ b.Property("ClientId")
+ .HasColumnType("integer");
b.HasKey("Id");
- b.HasIndex("UserId");
+ b.HasIndex("ClientId");
b.ToTable("Orders");
});
@@ -134,24 +134,24 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property("Id")
.ValueGeneratedOnAdd()
- .HasColumnType("int");
+ .HasColumnType("integer");
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("Email")
.IsRequired()
- .HasColumnType("nvarchar(max)");
+ .HasColumnType("text");
b.Property("Login")
.IsRequired()
- .HasColumnType("nvarchar(max)");
+ .HasColumnType("text");
b.Property("Password")
.IsRequired()
- .HasColumnType("nvarchar(max)");
+ .HasColumnType("text");
b.Property("Role")
- .HasColumnType("int");
+ .HasColumnType("integer");
b.HasKey("Id");
@@ -162,23 +162,26 @@ namespace HardwareShopDatabaseImplement.Migrations
{
b.Property("Id")
.ValueGeneratedOnAdd()
- .HasColumnType("int");
+ .HasColumnType("integer");
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("BuildName")
.IsRequired()
- .HasColumnType("nvarchar(max)");
+ .HasColumnType("text");
+
+ b.Property("ClientId")
+ .HasColumnType("integer");
b.Property("Price")
- .HasColumnType("decimal(18,2)");
+ .HasColumnType("numeric");
b.Property("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("Id")
.ValueGeneratedOnAdd()
- .HasColumnType("int");
+ .HasColumnType("integer");
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("BuildId")
- .HasColumnType("int");
+ .HasColumnType("integer");
+
+ b.Property("ClientId")
+ .HasColumnType("integer");
b.Property("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("Id")
.ValueGeneratedOnAdd()
- .HasColumnType("int");
+ .HasColumnType("integer");
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ClientId")
+ .HasColumnType("integer");
b.Property("DatePurchase")
- .HasColumnType("datetime2");
+ .HasColumnType("timestamp with time zone");
b.Property("PurchaseStatus")
- .HasColumnType("int");
+ .HasColumnType("integer");
b.Property("Sum")
- .HasColumnType("decimal(18,2)");
+ .HasColumnType("numeric");
b.Property("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");