Files
CartriX/CartriX.Api/Migrations/20260529165427_Init1.cs
T

520 lines
22 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace CartriX.Api.Migrations
{
/// <inheritdoc />
public partial class Init1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CartridgeArticle",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true)
},
constraints: table =>
{
table.PrimaryKey("PK_CartridgeArticle", x => x.Id);
});
migrationBuilder.CreateTable(
name: "CartridgeStatuses",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CartridgeStatuses", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Locations",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Locations", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Manufacturers",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
picturePath = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Manufacturers", x => x.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: "PrinterConnetctionTypes",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PrinterConnetctionTypes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "PrinterPrintTypes",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PrinterPrintTypes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "PrinterStatuses",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PrinterStatuses", x => x.Id);
});
migrationBuilder.CreateTable(
name: "CartridgeModels",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
ManufacturerId = table.Column<int>(type: "INTEGER", nullable: false),
CartridgeArticleId = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_CartridgeModels", x => x.Id);
table.ForeignKey(
name: "FK_CartridgeModels_CartridgeArticle_CartridgeArticleId",
column: x => x.CartridgeArticleId,
principalTable: "CartridgeArticle",
principalColumn: "Id");
table.ForeignKey(
name: "FK_CartridgeModels_Manufacturers_ManufacturerId",
column: x => x.ManufacturerId,
principalTable: "Manufacturers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Articles",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
CartridgeModelId = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Articles", x => x.Id);
table.ForeignKey(
name: "FK_Articles_CartridgeModels_CartridgeModelId",
column: x => x.CartridgeModelId,
principalTable: "CartridgeModels",
principalColumn: "Id");
});
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_CartridgeArticle_SupportedCartridgesId",
column: x => x.SupportedCartridgesId,
principalTable: "CartridgeArticle",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
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.CreateTable(
name: "PrinterModels",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
ManufacturerId = table.Column<int>(type: "INTEGER", nullable: false),
SupportedArticleId = table.Column<int>(type: "INTEGER", nullable: false),
PrinterArticleId = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PrinterModels", x => x.Id);
table.ForeignKey(
name: "FK_PrinterModels_Articles_SupportedArticleId",
column: x => x.SupportedArticleId,
principalTable: "Articles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PrinterModels_Manufacturers_ManufacturerId",
column: x => x.ManufacturerId,
principalTable: "Manufacturers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PrinterModels_PrinterArticle_PrinterArticleId",
column: x => x.PrinterArticleId,
principalTable: "PrinterArticle",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Printers",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
IpAddressOrHostname = table.Column<string>(type: "TEXT", nullable: true),
CountPrintedAllTime = table.Column<int>(type: "INTEGER", nullable: false),
OidForQueryCountPrintedAllTime = table.Column<string>(type: "TEXT", nullable: true),
PrintTypeId = table.Column<int>(type: "INTEGER", nullable: false),
ModelId = table.Column<int>(type: "INTEGER", nullable: false),
PrinterStatusId = table.Column<int>(type: "INTEGER", nullable: false),
PrinterConnetctionTypeId = table.Column<int>(type: "INTEGER", nullable: false),
LocationId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Printers", x => x.Id);
table.ForeignKey(
name: "FK_Printers_Locations_LocationId",
column: x => x.LocationId,
principalTable: "Locations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Printers_PrinterConnetctionTypes_PrinterConnetctionTypeId",
column: x => x.PrinterConnetctionTypeId,
principalTable: "PrinterConnetctionTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Printers_PrinterModels_ModelId",
column: x => x.ModelId,
principalTable: "PrinterModels",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Printers_PrinterPrintTypes_PrintTypeId",
column: x => x.PrintTypeId,
principalTable: "PrinterPrintTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Printers_PrinterStatuses_PrinterStatusId",
column: x => x.PrinterStatusId,
principalTable: "PrinterStatuses",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Cartridges",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
ModelId = table.Column<int>(type: "INTEGER", nullable: false),
Volume = table.Column<int>(type: "INTEGER", nullable: false),
DateLastFilling = table.Column<DateOnly>(type: "TEXT", nullable: true),
CountPrinted = table.Column<int>(type: "INTEGER", nullable: false),
InstalledInPrinterId = table.Column<int>(type: "INTEGER", nullable: true),
StatusId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Cartridges", x => x.Id);
table.ForeignKey(
name: "FK_Cartridges_CartridgeModels_ModelId",
column: x => x.ModelId,
principalTable: "CartridgeModels",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Cartridges_CartridgeStatuses_StatusId",
column: x => x.StatusId,
principalTable: "CartridgeStatuses",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Cartridges_Printers_InstalledInPrinterId",
column: x => x.InstalledInPrinterId,
principalTable: "Printers",
principalColumn: "Id");
});
migrationBuilder.InsertData(
table: "CartridgeStatuses",
columns: new[] { "Id", "Name" },
values: new object[,]
{
{ 1, "Установлен" },
{ 2, "На склаже" },
{ 3, "На заправке" },
{ 4, "В очереди на заправку" },
{ 5, "В ремонте" }
});
migrationBuilder.InsertData(
table: "Manufacturers",
columns: new[] { "Id", "Name", "picturePath" },
values: new object[] { 1, "Неизвестен", null });
migrationBuilder.InsertData(
table: "PrinterConnetctionTypes",
columns: new[] { "Id", "Name" },
values: new object[,]
{
{ 1, "Сетевой" },
{ 2, "USB" }
});
migrationBuilder.InsertData(
table: "PrinterPrintTypes",
columns: new[] { "Id", "Name" },
values: new object[,]
{
{ 1, "Лазерный" },
{ 2, "Струйный" }
});
migrationBuilder.InsertData(
table: "PrinterStatuses",
columns: new[] { "Id", "Name" },
values: new object[,]
{
{ 1, "Активный" },
{ 2, "Недоступен" },
{ 3, "В ремонте" }
});
migrationBuilder.CreateIndex(
name: "IX_ArticleCartridgeArticle_SupportedCartridgesId",
table: "ArticleCartridgeArticle",
column: "SupportedCartridgesId");
migrationBuilder.CreateIndex(
name: "IX_ArticlePrinterArticle_SupportedPrintersId",
table: "ArticlePrinterArticle",
column: "SupportedPrintersId");
migrationBuilder.CreateIndex(
name: "IX_Articles_CartridgeModelId",
table: "Articles",
column: "CartridgeModelId");
migrationBuilder.CreateIndex(
name: "IX_CartridgeModels_CartridgeArticleId",
table: "CartridgeModels",
column: "CartridgeArticleId");
migrationBuilder.CreateIndex(
name: "IX_CartridgeModels_ManufacturerId",
table: "CartridgeModels",
column: "ManufacturerId");
migrationBuilder.CreateIndex(
name: "IX_Cartridges_InstalledInPrinterId",
table: "Cartridges",
column: "InstalledInPrinterId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Cartridges_ModelId",
table: "Cartridges",
column: "ModelId");
migrationBuilder.CreateIndex(
name: "IX_Cartridges_StatusId",
table: "Cartridges",
column: "StatusId");
migrationBuilder.CreateIndex(
name: "IX_Locations_Name",
table: "Locations",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_PrinterModels_ManufacturerId",
table: "PrinterModels",
column: "ManufacturerId");
migrationBuilder.CreateIndex(
name: "IX_PrinterModels_PrinterArticleId",
table: "PrinterModels",
column: "PrinterArticleId");
migrationBuilder.CreateIndex(
name: "IX_PrinterModels_SupportedArticleId",
table: "PrinterModels",
column: "SupportedArticleId");
migrationBuilder.CreateIndex(
name: "IX_Printers_LocationId",
table: "Printers",
column: "LocationId");
migrationBuilder.CreateIndex(
name: "IX_Printers_ModelId",
table: "Printers",
column: "ModelId");
migrationBuilder.CreateIndex(
name: "IX_Printers_Name",
table: "Printers",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Printers_PrinterConnetctionTypeId",
table: "Printers",
column: "PrinterConnetctionTypeId");
migrationBuilder.CreateIndex(
name: "IX_Printers_PrinterStatusId",
table: "Printers",
column: "PrinterStatusId");
migrationBuilder.CreateIndex(
name: "IX_Printers_PrintTypeId",
table: "Printers",
column: "PrintTypeId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ArticleCartridgeArticle");
migrationBuilder.DropTable(
name: "ArticlePrinterArticle");
migrationBuilder.DropTable(
name: "Cartridges");
migrationBuilder.DropTable(
name: "CartridgeStatuses");
migrationBuilder.DropTable(
name: "Printers");
migrationBuilder.DropTable(
name: "Locations");
migrationBuilder.DropTable(
name: "PrinterConnetctionTypes");
migrationBuilder.DropTable(
name: "PrinterModels");
migrationBuilder.DropTable(
name: "PrinterPrintTypes");
migrationBuilder.DropTable(
name: "PrinterStatuses");
migrationBuilder.DropTable(
name: "Articles");
migrationBuilder.DropTable(
name: "PrinterArticle");
migrationBuilder.DropTable(
name: "CartridgeModels");
migrationBuilder.DropTable(
name: "CartridgeArticle");
migrationBuilder.DropTable(
name: "Manufacturers");
}
}
}