Files
ECommerce/ECommerce.Domain/Migrations/20260110093153_ModelUpdate.cs
T

101 lines
3.3 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Commerce.Domain.Migrations
{
/// <inheritdoc />
public partial class ModelUpdate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Categorys_Categorys_ParentCategoryId",
table: "Categorys");
migrationBuilder.DropForeignKey(
name: "FK_Products_Categorys_CategoryId",
table: "Products");
migrationBuilder.DropPrimaryKey(
name: "PK_Categorys",
table: "Categorys");
migrationBuilder.RenameTable(
name: "Categorys",
newName: "Categories");
migrationBuilder.RenameIndex(
name: "IX_Categorys_ParentCategoryId",
table: "Categories",
newName: "IX_Categories_ParentCategoryId");
migrationBuilder.AddPrimaryKey(
name: "PK_Categories",
table: "Categories",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Categories_Categories_ParentCategoryId",
table: "Categories",
column: "ParentCategoryId",
principalTable: "Categories",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Products_Categories_CategoryId",
table: "Products",
column: "CategoryId",
principalTable: "Categories",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Categories_Categories_ParentCategoryId",
table: "Categories");
migrationBuilder.DropForeignKey(
name: "FK_Products_Categories_CategoryId",
table: "Products");
migrationBuilder.DropPrimaryKey(
name: "PK_Categories",
table: "Categories");
migrationBuilder.RenameTable(
name: "Categories",
newName: "Categorys");
migrationBuilder.RenameIndex(
name: "IX_Categories_ParentCategoryId",
table: "Categorys",
newName: "IX_Categorys_ParentCategoryId");
migrationBuilder.AddPrimaryKey(
name: "PK_Categorys",
table: "Categorys",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Categorys_Categorys_ParentCategoryId",
table: "Categorys",
column: "ParentCategoryId",
principalTable: "Categorys",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Products_Categorys_CategoryId",
table: "Products",
column: "CategoryId",
principalTable: "Categorys",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}