mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-05 20:40:55 +00:00
113 lines
4.1 KiB
C#
113 lines
4.1 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace CartriX.Api.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Init4 : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_Articles_Printers_SupportedPrinterId",
|
|
table: "Articles");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ArticleCartridgeArticle");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Articles_SupportedPrinterId",
|
|
table: "Articles");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "SupportedPrinterId",
|
|
table: "Articles");
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "CartridgeArticleId",
|
|
table: "Articles",
|
|
type: "INTEGER",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Articles_CartridgeArticleId",
|
|
table: "Articles",
|
|
column: "CartridgeArticleId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_Articles_CartridgeArticles_CartridgeArticleId",
|
|
table: "Articles",
|
|
column: "CartridgeArticleId",
|
|
principalTable: "CartridgeArticles",
|
|
principalColumn: "Id");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_Articles_CartridgeArticles_CartridgeArticleId",
|
|
table: "Articles");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Articles_CartridgeArticleId",
|
|
table: "Articles");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "CartridgeArticleId",
|
|
table: "Articles");
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "SupportedPrinterId",
|
|
table: "Articles",
|
|
type: "INTEGER",
|
|
nullable: false,
|
|
defaultValue: 0);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ArticleCartridgeArticle",
|
|
columns: table => new
|
|
{
|
|
ArticleId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
SupportedCartridgesId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ArticleCartridgeArticle", x => new { x.ArticleId, x.SupportedCartridgesId });
|
|
table.ForeignKey(
|
|
name: "FK_ArticleCartridgeArticle_Articles_ArticleId",
|
|
column: x => x.ArticleId,
|
|
principalTable: "Articles",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_ArticleCartridgeArticle_CartridgeArticles_SupportedCartridgesId",
|
|
column: x => x.SupportedCartridgesId,
|
|
principalTable: "CartridgeArticles",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Articles_SupportedPrinterId",
|
|
table: "Articles",
|
|
column: "SupportedPrinterId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ArticleCartridgeArticle_SupportedCartridgesId",
|
|
table: "ArticleCartridgeArticle",
|
|
column: "SupportedCartridgesId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_Articles_Printers_SupportedPrinterId",
|
|
table: "Articles",
|
|
column: "SupportedPrinterId",
|
|
principalTable: "Printers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
}
|
|
}
|
|
}
|