mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-05 20:40:55 +00:00
200 lines
7.5 KiB
C#
200 lines
7.5 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace CartriX.Api.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Init2 : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_ArticleCartridgeArticle_CartridgeArticle_SupportedCartridgesId",
|
|
table: "ArticleCartridgeArticle");
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_CartridgeModels_CartridgeArticle_CartridgeArticleId",
|
|
table: "CartridgeModels");
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_PrinterModels_PrinterArticle_PrinterArticleId",
|
|
table: "PrinterModels");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ArticlePrinterArticle");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "PrinterArticle");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_PrinterModels_PrinterArticleId",
|
|
table: "PrinterModels");
|
|
|
|
migrationBuilder.DropPrimaryKey(
|
|
name: "PK_CartridgeArticle",
|
|
table: "CartridgeArticle");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "PrinterArticleId",
|
|
table: "PrinterModels");
|
|
|
|
migrationBuilder.RenameTable(
|
|
name: "CartridgeArticle",
|
|
newName: "CartridgeArticles");
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "SupportedPrinterId",
|
|
table: "Articles",
|
|
type: "INTEGER",
|
|
nullable: false,
|
|
defaultValue: 0);
|
|
|
|
migrationBuilder.AddPrimaryKey(
|
|
name: "PK_CartridgeArticles",
|
|
table: "CartridgeArticles",
|
|
column: "Id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Articles_SupportedPrinterId",
|
|
table: "Articles",
|
|
column: "SupportedPrinterId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_ArticleCartridgeArticle_CartridgeArticles_SupportedCartridgesId",
|
|
table: "ArticleCartridgeArticle",
|
|
column: "SupportedCartridgesId",
|
|
principalTable: "CartridgeArticles",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_Articles_Printers_SupportedPrinterId",
|
|
table: "Articles",
|
|
column: "SupportedPrinterId",
|
|
principalTable: "Printers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_CartridgeModels_CartridgeArticles_CartridgeArticleId",
|
|
table: "CartridgeModels",
|
|
column: "CartridgeArticleId",
|
|
principalTable: "CartridgeArticles",
|
|
principalColumn: "Id");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_ArticleCartridgeArticle_CartridgeArticles_SupportedCartridgesId",
|
|
table: "ArticleCartridgeArticle");
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_Articles_Printers_SupportedPrinterId",
|
|
table: "Articles");
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_CartridgeModels_CartridgeArticles_CartridgeArticleId",
|
|
table: "CartridgeModels");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Articles_SupportedPrinterId",
|
|
table: "Articles");
|
|
|
|
migrationBuilder.DropPrimaryKey(
|
|
name: "PK_CartridgeArticles",
|
|
table: "CartridgeArticles");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "SupportedPrinterId",
|
|
table: "Articles");
|
|
|
|
migrationBuilder.RenameTable(
|
|
name: "CartridgeArticles",
|
|
newName: "CartridgeArticle");
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "PrinterArticleId",
|
|
table: "PrinterModels",
|
|
type: "INTEGER",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddPrimaryKey(
|
|
name: "PK_CartridgeArticle",
|
|
table: "CartridgeArticle",
|
|
column: "Id");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "PrinterArticle",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_PrinterArticle", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ArticlePrinterArticle",
|
|
columns: table => new
|
|
{
|
|
ArticleId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
SupportedPrintersId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ArticlePrinterArticle", x => new { x.ArticleId, x.SupportedPrintersId });
|
|
table.ForeignKey(
|
|
name: "FK_ArticlePrinterArticle_Articles_ArticleId",
|
|
column: x => x.ArticleId,
|
|
principalTable: "Articles",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_ArticlePrinterArticle_PrinterArticle_SupportedPrintersId",
|
|
column: x => x.SupportedPrintersId,
|
|
principalTable: "PrinterArticle",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PrinterModels_PrinterArticleId",
|
|
table: "PrinterModels",
|
|
column: "PrinterArticleId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ArticlePrinterArticle_SupportedPrintersId",
|
|
table: "ArticlePrinterArticle",
|
|
column: "SupportedPrintersId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_ArticleCartridgeArticle_CartridgeArticle_SupportedCartridgesId",
|
|
table: "ArticleCartridgeArticle",
|
|
column: "SupportedCartridgesId",
|
|
principalTable: "CartridgeArticle",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_CartridgeModels_CartridgeArticle_CartridgeArticleId",
|
|
table: "CartridgeModels",
|
|
column: "CartridgeArticleId",
|
|
principalTable: "CartridgeArticle",
|
|
principalColumn: "Id");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_PrinterModels_PrinterArticle_PrinterArticleId",
|
|
table: "PrinterModels",
|
|
column: "PrinterArticleId",
|
|
principalTable: "PrinterArticle",
|
|
principalColumn: "Id");
|
|
}
|
|
}
|
|
}
|