From 5b43c731bb8163fb3b5adcba7ec3df6b0a18e263 Mon Sep 17 00:00:00 2001 From: Marselchi Date: Wed, 29 May 2024 00:17:29 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=87=D0=B8=D0=BD=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BC=D0=B8=D0=B3=D1=80=D0=B0=D1=86=D0=B8=D1=8E,=20=D0=B2?= =?UTF-8?q?=D0=BE=D0=B2=D0=B7=D1=80=D0=B0=D1=89=D0=B0=D1=8E=D1=81=D1=8C=20?= =?UTF-8?q?=D0=B2=20=D0=B2=D0=B5=D1=82=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Migrations/20240528191551_InitFull.cs | 19 - ...cs => 20240528201628_InitFull.Designer.cs} | 2 +- .../Migrations/20240528201628_InitFull.cs | 352 ++++++++++++++++++ 3 files changed, 353 insertions(+), 20 deletions(-) delete mode 100644 CarCenter/CarCenterDatabaseImplement/Migrations/20240528191551_InitFull.cs rename CarCenter/CarCenterDatabaseImplement/Migrations/{20240528191551_InitFull.Designer.cs => 20240528201628_InitFull.Designer.cs} (99%) create mode 100644 CarCenter/CarCenterDatabaseImplement/Migrations/20240528201628_InitFull.cs diff --git a/CarCenter/CarCenterDatabaseImplement/Migrations/20240528191551_InitFull.cs b/CarCenter/CarCenterDatabaseImplement/Migrations/20240528191551_InitFull.cs deleted file mode 100644 index 12b50a3..0000000 --- a/CarCenter/CarCenterDatabaseImplement/Migrations/20240528191551_InitFull.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace CarCenterDatabaseImplement.Migrations -{ - public partial class InitFull : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/CarCenter/CarCenterDatabaseImplement/Migrations/20240528191551_InitFull.Designer.cs b/CarCenter/CarCenterDatabaseImplement/Migrations/20240528201628_InitFull.Designer.cs similarity index 99% rename from CarCenter/CarCenterDatabaseImplement/Migrations/20240528191551_InitFull.Designer.cs rename to CarCenter/CarCenterDatabaseImplement/Migrations/20240528201628_InitFull.Designer.cs index 03d2eaa..b1d3881 100644 --- a/CarCenter/CarCenterDatabaseImplement/Migrations/20240528191551_InitFull.Designer.cs +++ b/CarCenter/CarCenterDatabaseImplement/Migrations/20240528201628_InitFull.Designer.cs @@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace CarCenterDatabaseImplement.Migrations { [DbContext(typeof(CarCenterDatabase))] - [Migration("20240528191551_InitFull")] + [Migration("20240528201628_InitFull")] partial class InitFull { protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/CarCenter/CarCenterDatabaseImplement/Migrations/20240528201628_InitFull.cs b/CarCenter/CarCenterDatabaseImplement/Migrations/20240528201628_InitFull.cs new file mode 100644 index 0000000..bc836fd --- /dev/null +++ b/CarCenter/CarCenterDatabaseImplement/Migrations/20240528201628_InitFull.cs @@ -0,0 +1,352 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace CarCenterDatabaseImplement.Migrations +{ + public partial class InitFull : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Bundlings", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + StorekeeperId = table.Column(type: "integer", nullable: false), + EquipmentPackage = table.Column(type: "integer", nullable: false), + TirePackage = table.Column(type: "integer", nullable: false), + ToolKit = table.Column(type: "integer", nullable: false), + Price = table.Column(type: "double precision", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Bundlings", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Features", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + StorekeeperId = table.Column(type: "integer", nullable: false), + HelpDevice = table.Column(type: "integer", nullable: false), + CabinColor = table.Column(type: "text", nullable: false), + DriveType = table.Column(type: "integer", nullable: false), + Price = table.Column(type: "double precision", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Features", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Presales", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + PresaleStatus = table.Column(type: "integer", nullable: false), + Description = table.Column(type: "text", nullable: false), + DueTill = table.Column(type: "timestamp without time zone", nullable: false), + Price = table.Column(type: "double precision", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Presales", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Storekeepers", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + Surname = table.Column(type: "text", nullable: false), + Patronymic = table.Column(type: "text", nullable: true), + Password = table.Column(type: "text", nullable: false), + Email = table.Column(type: "text", nullable: false), + PhoneNumber = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Storekeepers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Workers", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + Surname = table.Column(type: "text", nullable: false), + Patronymic = table.Column(type: "text", nullable: true), + Password = table.Column(type: "text", nullable: false), + Email = table.Column(type: "text", nullable: false), + PhoneNumber = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Workers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "PresaleBundlings", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + PresaleId = table.Column(type: "integer", nullable: false), + BundlingId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PresaleBundlings", x => x.Id); + table.ForeignKey( + name: "FK_PresaleBundlings_Bundlings_BundlingId", + column: x => x.BundlingId, + principalTable: "Bundlings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_PresaleBundlings_Presales_PresaleId", + column: x => x.PresaleId, + principalTable: "Presales", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Requests", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + PresaleId = table.Column(type: "integer", nullable: false), + Description = table.Column(type: "text", nullable: false), + RequestType = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Requests", x => x.Id); + table.ForeignKey( + name: "FK_Requests_Presales_PresaleId", + column: x => x.PresaleId, + principalTable: "Presales", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Orders", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + WorkerId = table.Column(type: "integer", nullable: false), + PaymentType = table.Column(type: "integer", nullable: false), + PaymentStatus = table.Column(type: "integer", nullable: false), + BuyerFCS = table.Column(type: "text", nullable: false), + PaymentDate = table.Column(type: "timestamp without time zone", nullable: false), + Sum = table.Column(type: "double precision", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Orders", x => x.Id); + table.ForeignKey( + name: "FK_Orders_Workers_WorkerId", + column: x => x.WorkerId, + principalTable: "Workers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Cars", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + StorekeeperId = table.Column(type: "integer", nullable: false), + OrderId = table.Column(type: "integer", nullable: true), + FeatureId = table.Column(type: "integer", nullable: true), + CarBrand = table.Column(type: "integer", nullable: false), + Model = table.Column(type: "text", nullable: false), + CarClass = table.Column(type: "integer", nullable: false), + Year = table.Column(type: "integer", nullable: false), + Price = table.Column(type: "double precision", nullable: false), + VINnumber = table.Column(type: "bigint", nullable: false), + FeatureID = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Cars", x => x.Id); + table.ForeignKey( + name: "FK_Cars_Features_FeatureId", + column: x => x.FeatureId, + principalTable: "Features", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Cars_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Cars_Storekeepers_StorekeeperId", + column: x => x.StorekeeperId, + principalTable: "Storekeepers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "OrderPresales", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + OrderId = table.Column(type: "integer", nullable: false), + PresaleId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_OrderPresales", x => x.Id); + table.ForeignKey( + name: "FK_OrderPresales_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_OrderPresales_Presales_PresaleId", + column: x => x.PresaleId, + principalTable: "Presales", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "CarBundlings", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + CarId = table.Column(type: "integer", nullable: false), + BundlingId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CarBundlings", x => x.Id); + table.ForeignKey( + name: "FK_CarBundlings_Bundlings_BundlingId", + column: x => x.BundlingId, + principalTable: "Bundlings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_CarBundlings_Cars_CarId", + column: x => x.CarId, + principalTable: "Cars", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_CarBundlings_BundlingId", + table: "CarBundlings", + column: "BundlingId"); + + migrationBuilder.CreateIndex( + name: "IX_CarBundlings_CarId", + table: "CarBundlings", + column: "CarId"); + + migrationBuilder.CreateIndex( + name: "IX_Cars_FeatureId", + table: "Cars", + column: "FeatureId"); + + migrationBuilder.CreateIndex( + name: "IX_Cars_OrderId", + table: "Cars", + column: "OrderId"); + + migrationBuilder.CreateIndex( + name: "IX_Cars_StorekeeperId", + table: "Cars", + column: "StorekeeperId"); + + migrationBuilder.CreateIndex( + name: "IX_OrderPresales_OrderId", + table: "OrderPresales", + column: "OrderId"); + + migrationBuilder.CreateIndex( + name: "IX_OrderPresales_PresaleId", + table: "OrderPresales", + column: "PresaleId"); + + migrationBuilder.CreateIndex( + name: "IX_Orders_WorkerId", + table: "Orders", + column: "WorkerId"); + + migrationBuilder.CreateIndex( + name: "IX_PresaleBundlings_BundlingId", + table: "PresaleBundlings", + column: "BundlingId"); + + migrationBuilder.CreateIndex( + name: "IX_PresaleBundlings_PresaleId", + table: "PresaleBundlings", + column: "PresaleId"); + + migrationBuilder.CreateIndex( + name: "IX_Requests_PresaleId", + table: "Requests", + column: "PresaleId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "CarBundlings"); + + migrationBuilder.DropTable( + name: "OrderPresales"); + + migrationBuilder.DropTable( + name: "PresaleBundlings"); + + migrationBuilder.DropTable( + name: "Requests"); + + migrationBuilder.DropTable( + name: "Cars"); + + migrationBuilder.DropTable( + name: "Bundlings"); + + migrationBuilder.DropTable( + name: "Presales"); + + migrationBuilder.DropTable( + name: "Features"); + + migrationBuilder.DropTable( + name: "Orders"); + + migrationBuilder.DropTable( + name: "Storekeepers"); + + migrationBuilder.DropTable( + name: "Workers"); + } + } +} -- 2.25.1