Починил миграцию, вовзращаюсь в ветку

This commit is contained in:
Marselchi 2024-05-29 00:17:29 +04:00
parent d37d512aa4
commit 5b43c731bb
3 changed files with 353 additions and 20 deletions

View File

@ -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)
{
}
}
}

View File

@ -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)

View File

@ -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<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
StorekeeperId = table.Column<int>(type: "integer", nullable: false),
EquipmentPackage = table.Column<int>(type: "integer", nullable: false),
TirePackage = table.Column<int>(type: "integer", nullable: false),
ToolKit = table.Column<int>(type: "integer", nullable: false),
Price = table.Column<double>(type: "double precision", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Bundlings", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Features",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
StorekeeperId = table.Column<int>(type: "integer", nullable: false),
HelpDevice = table.Column<int>(type: "integer", nullable: false),
CabinColor = table.Column<string>(type: "text", nullable: false),
DriveType = table.Column<int>(type: "integer", nullable: false),
Price = table.Column<double>(type: "double precision", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Features", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Presales",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
PresaleStatus = table.Column<int>(type: "integer", nullable: false),
Description = table.Column<string>(type: "text", nullable: false),
DueTill = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
Price = table.Column<double>(type: "double precision", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Presales", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Storekeepers",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
Surname = table.Column<string>(type: "text", nullable: false),
Patronymic = table.Column<string>(type: "text", nullable: true),
Password = table.Column<string>(type: "text", nullable: false),
Email = table.Column<string>(type: "text", nullable: false),
PhoneNumber = table.Column<long>(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Storekeepers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Workers",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
Surname = table.Column<string>(type: "text", nullable: false),
Patronymic = table.Column<string>(type: "text", nullable: true),
Password = table.Column<string>(type: "text", nullable: false),
Email = table.Column<string>(type: "text", nullable: false),
PhoneNumber = table.Column<long>(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Workers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "PresaleBundlings",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
PresaleId = table.Column<int>(type: "integer", nullable: false),
BundlingId = table.Column<int>(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<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
PresaleId = table.Column<int>(type: "integer", nullable: false),
Description = table.Column<string>(type: "text", nullable: false),
RequestType = table.Column<int>(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<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
WorkerId = table.Column<int>(type: "integer", nullable: false),
PaymentType = table.Column<int>(type: "integer", nullable: false),
PaymentStatus = table.Column<int>(type: "integer", nullable: false),
BuyerFCS = table.Column<string>(type: "text", nullable: false),
PaymentDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
Sum = table.Column<double>(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<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
StorekeeperId = table.Column<int>(type: "integer", nullable: false),
OrderId = table.Column<int>(type: "integer", nullable: true),
FeatureId = table.Column<int>(type: "integer", nullable: true),
CarBrand = table.Column<int>(type: "integer", nullable: false),
Model = table.Column<string>(type: "text", nullable: false),
CarClass = table.Column<int>(type: "integer", nullable: false),
Year = table.Column<int>(type: "integer", nullable: false),
Price = table.Column<double>(type: "double precision", nullable: false),
VINnumber = table.Column<long>(type: "bigint", nullable: false),
FeatureID = table.Column<int>(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<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
OrderId = table.Column<int>(type: "integer", nullable: false),
PresaleId = table.Column<int>(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<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
CarId = table.Column<int>(type: "integer", nullable: false),
BundlingId = table.Column<int>(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");
}
}
}