This commit is contained in:
2025-04-25 10:36:53 +04:00
parent b331b2f885
commit e7fdf6e526
2 changed files with 211 additions and 121 deletions

View File

@@ -1,26 +1,26 @@
// <auto-generated />
using System;
using CandyHouseDatabase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using CandyHouseDatabase;
#nullable disable
namespace CandyHouseDataBase.Migrations
namespace CandyHouseDatabase.Migrations
{
[DbContext(typeof(CandyHouseDbContext))]
[Migration("20250414205534_InitialCreate")]
partial class InitialCreate
[Migration("20250409185826_FirstMigration")]
partial class FirstMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.3")
.HasAnnotation("ProductVersion", "9.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@@ -30,8 +30,9 @@ namespace CandyHouseDataBase.Migrations
b.Property<string>("Id")
.HasColumnType("text");
b.Property<double>("DiscountSize")
.HasColumnType("double precision");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FIO")
.IsRequired()
@@ -43,44 +44,58 @@ namespace CandyHouseDataBase.Migrations
b.HasKey("Id");
b.HasIndex("Email")
.IsUnique();
b.HasIndex("PhoneNumber")
.IsUnique();
b.ToTable("Clients");
});
modelBuilder.Entity("CandyHouseDatabase.Models.Employee", b =>
modelBuilder.Entity("CandyHouseDatabase.Models.ClientDiscount", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp with time zone");
b.Property<DateTime?>("DateOfDelete")
.HasColumnType("timestamp with time zone");
b.Property<string>("Email")
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("EmploymentDate")
.HasColumnType("timestamp with time zone");
b.Property<double>("DiscountAmount")
.HasColumnType("double precision");
b.Property<string>("FIO")
b.Property<DateTime>("DiscountDate")
.HasColumnType("timestamp without time zone");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("ClientDiscounts");
});
modelBuilder.Entity("CandyHouseDatabase.Models.Manufacturer", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("ManufacturerName")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsDeleted")
.HasColumnType("boolean");
b.Property<string>("PrevManufacturerName")
.HasColumnType("text");
b.Property<string>("PostId")
.IsRequired()
b.Property<string>("PrevPrevManufacturerName")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Employees");
b.HasIndex("ManufacturerName")
.IsUnique();
b.ToTable("Manufacturers");
});
modelBuilder.Entity("CandyHouseDatabase.Models.Post", b =>
@@ -89,11 +104,7 @@ namespace CandyHouseDataBase.Migrations
.HasColumnType("text");
b.Property<DateTime>("ChangeDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Configuration")
.IsRequired()
.HasColumnType("jsonb");
.HasColumnType("timestamp without time zone");
b.Property<bool>("IsActual")
.HasColumnType("boolean");
@@ -109,6 +120,9 @@ namespace CandyHouseDataBase.Migrations
b.Property<int>("PostType")
.HasColumnType("integer");
b.Property<double>("Salary")
.HasColumnType("double precision");
b.HasKey("Id");
b.HasIndex("PostId", "IsActual")
@@ -127,12 +141,22 @@ namespace CandyHouseDataBase.Migrations
b.Property<string>("Id")
.HasColumnType("text");
b.Property<bool>("IsDeleted")
.HasColumnType("boolean");
b.Property<string>("ManufacturerId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PrevPrevProductName")
.HasColumnType("text");
b.Property<string>("PrevProductName")
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<string>("ProductDescription")
.HasColumnType("text");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("text");
@@ -142,8 +166,11 @@ namespace CandyHouseDataBase.Migrations
b.HasKey("Id");
b.HasIndex("ProductName")
.IsUnique();
b.HasIndex("ManufacturerId");
b.HasIndex("ProductName", "IsDeleted")
.IsUnique()
.HasFilter("\"IsDeleted\" = FALSE");
b.ToTable("Products");
});
@@ -154,7 +181,7 @@ namespace CandyHouseDataBase.Migrations
.HasColumnType("text");
b.Property<DateTime>("ChangeDate")
.HasColumnType("timestamp with time zone");
.HasColumnType("timestamp without time zone");
b.Property<double>("OldPrice")
.HasColumnType("double precision");
@@ -170,28 +197,6 @@ namespace CandyHouseDataBase.Migrations
b.ToTable("ProductHistories");
});
modelBuilder.Entity("CandyHouseDatabase.Models.Salary", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("EmployeeId")
.IsRequired()
.HasColumnType("text");
b.Property<double>("EmployeeSalary")
.HasColumnType("double precision");
b.Property<DateTime>("SalaryDate")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("EmployeeId");
b.ToTable("Salaries");
});
modelBuilder.Entity("CandyHouseDatabase.Models.Sale", b =>
{
b.Property<string>("Id")
@@ -206,19 +211,19 @@ namespace CandyHouseDataBase.Migrations
b.Property<int>("DiscountType")
.HasColumnType("integer");
b.Property<string>("EmployeeId")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsCancel")
.HasColumnType("boolean");
b.Property<DateTime>("SaleDate")
.HasColumnType("timestamp with time zone");
.HasColumnType("timestamp without time zone");
b.Property<double>("Sum")
.HasColumnType("double precision");
b.Property<string>("EmployeeId")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ClientId");
@@ -249,6 +254,55 @@ namespace CandyHouseDataBase.Migrations
b.ToTable("SaleProducts");
});
modelBuilder.Entity("CandyHouseDatabase.Models.Employee", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("EmploymentDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("FIO")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsDeleted")
.HasColumnType("boolean");
b.Property<string>("PostId")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Employees");
});
modelBuilder.Entity("CandyHouseDatabase.Models.ClientDiscount", b =>
{
b.HasOne("CandyHouseDatabase.Models.Client", "Client")
.WithMany("ClientDiscounts")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("CandyHouseDatabase.Models.Product", b =>
{
b.HasOne("CandyHouseDatabase.Models.Manufacturer", "Manufacturer")
.WithMany("Products")
.HasForeignKey("ManufacturerId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Manufacturer");
});
modelBuilder.Entity("CandyHouseDatabase.Models.ProductHistory", b =>
{
b.HasOne("CandyHouseDatabase.Models.Product", "Product")
@@ -260,17 +314,6 @@ namespace CandyHouseDataBase.Migrations
b.Navigation("Product");
});
modelBuilder.Entity("CandyHouseDatabase.Models.Salary", b =>
{
b.HasOne("CandyHouseDatabase.Models.Employee", "Employee")
.WithMany("Salaries")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("CandyHouseDatabase.Models.Sale", b =>
{
b.HasOne("CandyHouseDatabase.Models.Client", "Client")
@@ -310,14 +353,14 @@ namespace CandyHouseDataBase.Migrations
modelBuilder.Entity("CandyHouseDatabase.Models.Client", b =>
{
b.Navigation("ClientDiscounts");
b.Navigation("Sales");
});
modelBuilder.Entity("CandyHouseDatabase.Models.Employee", b =>
modelBuilder.Entity("CandyHouseDatabase.Models.Manufacturer", b =>
{
b.Navigation("Salaries");
b.Navigation("Sales");
b.Navigation("Products");
});
modelBuilder.Entity("CandyHouseDatabase.Models.Product", b =>
@@ -331,6 +374,11 @@ namespace CandyHouseDataBase.Migrations
{
b.Navigation("SaleProducts");
});
modelBuilder.Entity("CandyHouseDatabase.Models.Employee", b =>
{
b.Navigation("Sales");
});
#pragma warning restore 612, 618
}
}

View File

@@ -3,10 +3,10 @@ using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CandyHouseDataBase.Migrations
namespace CandyHouseDatabase.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
public partial class FirstMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
@@ -18,7 +18,7 @@ namespace CandyHouseDataBase.Migrations
Id = table.Column<string>(type: "text", nullable: false),
FIO = table.Column<string>(type: "text", nullable: false),
PhoneNumber = table.Column<string>(type: "text", nullable: false),
DiscountSize = table.Column<double>(type: "double precision", nullable: false)
Email = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
@@ -26,21 +26,17 @@ namespace CandyHouseDataBase.Migrations
});
migrationBuilder.CreateTable(
name: "Employees",
name: "Manufacturers",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
FIO = table.Column<string>(type: "text", nullable: false),
Email = table.Column<string>(type: "text", nullable: false),
PostId = table.Column<string>(type: "text", nullable: false),
BirthDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
EmploymentDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
IsDeleted = table.Column<bool>(type: "boolean", nullable: false),
DateOfDelete = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
ManufacturerName = table.Column<string>(type: "text", nullable: false),
PrevManufacturerName = table.Column<string>(type: "text", nullable: true),
PrevPrevManufacturerName = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Employees", x => x.Id);
table.PrimaryKey("PK_Manufacturers", x => x.Id);
});
migrationBuilder.CreateTable(
@@ -51,48 +47,73 @@ namespace CandyHouseDataBase.Migrations
PostId = table.Column<string>(type: "text", nullable: false),
PostName = table.Column<string>(type: "text", nullable: false),
PostType = table.Column<int>(type: "integer", nullable: false),
Configuration = table.Column<string>(type: "jsonb", nullable: false),
Salary = table.Column<double>(type: "double precision", nullable: false),
IsActual = table.Column<bool>(type: "boolean", nullable: false),
ChangeDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
ChangeDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Posts", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Employees",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
FIO = table.Column<string>(type: "text", nullable: false),
PostId = table.Column<string>(type: "text", nullable: false),
BirthDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
EmploymentDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
IsDeleted = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Employees", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ClientDiscounts",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
ClientId = table.Column<string>(type: "text", nullable: false),
DiscountDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
DiscountAmount = table.Column<double>(type: "double precision", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientDiscounts", x => x.Id);
table.ForeignKey(
name: "FK_ClientDiscounts_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Products",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
ManufacturerId = table.Column<string>(type: "text", nullable: false),
ProductName = table.Column<string>(type: "text", nullable: false),
ProductDescription = table.Column<string>(type: "text", nullable: true),
ProductType = table.Column<int>(type: "integer", nullable: false),
Price = table.Column<double>(type: "double precision", nullable: false),
ProductType = table.Column<int>(type: "integer", nullable: false)
IsDeleted = table.Column<bool>(type: "boolean", nullable: false),
PrevProductName = table.Column<string>(type: "text", nullable: true),
PrevPrevProductName = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Products", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Salaries",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
EmployeeId = table.Column<string>(type: "text", nullable: false),
SalaryDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
EmployeeSalary = table.Column<double>(type: "double precision", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Salaries", x => x.Id);
table.ForeignKey(
name: "FK_Salaries_Employees_EmployeeId",
column: x => x.EmployeeId,
principalTable: "Employees",
name: "FK_Products_Manufacturers_ManufacturerId",
column: x => x.ManufacturerId,
principalTable: "Manufacturers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
@@ -102,7 +123,7 @@ namespace CandyHouseDataBase.Migrations
Id = table.Column<string>(type: "text", nullable: false),
EmployeeId = table.Column<string>(type: "text", nullable: false),
ClientId = table.Column<string>(type: "text", nullable: true),
SaleDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
SaleDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
Sum = table.Column<double>(type: "double precision", nullable: false),
DiscountType = table.Column<int>(type: "integer", nullable: false),
Discount = table.Column<double>(type: "double precision", nullable: false),
@@ -132,7 +153,7 @@ namespace CandyHouseDataBase.Migrations
Id = table.Column<string>(type: "text", nullable: false),
ProductId = table.Column<string>(type: "text", nullable: false),
OldPrice = table.Column<double>(type: "double precision", nullable: false),
ChangeDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
ChangeDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false)
},
constraints: table =>
{
@@ -171,12 +192,29 @@ namespace CandyHouseDataBase.Migrations
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ClientDiscounts_ClientId",
table: "ClientDiscounts",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_Clients_Email",
table: "Clients",
column: "Email",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Clients_PhoneNumber",
table: "Clients",
column: "PhoneNumber",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Manufacturers_ManufacturerName",
table: "Manufacturers",
column: "ManufacturerName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Posts_PostId_IsActual",
table: "Posts",
@@ -197,15 +235,16 @@ namespace CandyHouseDataBase.Migrations
column: "ProductId");
migrationBuilder.CreateIndex(
name: "IX_Products_ProductName",
name: "IX_Products_ManufacturerId",
table: "Products",
column: "ProductName",
unique: true);
column: "ManufacturerId");
migrationBuilder.CreateIndex(
name: "IX_Salaries_EmployeeId",
table: "Salaries",
column: "EmployeeId");
name: "IX_Products_ProductName_IsDeleted",
table: "Products",
columns: new[] { "ProductName", "IsDeleted" },
unique: true,
filter: "\"IsDeleted\" = FALSE");
migrationBuilder.CreateIndex(
name: "IX_SaleProducts_ProductId",
@@ -226,15 +265,15 @@ namespace CandyHouseDataBase.Migrations
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ClientDiscounts");
migrationBuilder.DropTable(
name: "Posts");
migrationBuilder.DropTable(
name: "ProductHistories");
migrationBuilder.DropTable(
name: "Salaries");
migrationBuilder.DropTable(
name: "SaleProducts");
@@ -244,6 +283,9 @@ namespace CandyHouseDataBase.Migrations
migrationBuilder.DropTable(
name: "Sales");
migrationBuilder.DropTable(
name: "Manufacturers");
migrationBuilder.DropTable(
name: "Clients");