mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-05 20:40:55 +00:00
Добавил страницу по замене картриджа Создал новую сущность базы данных, ReqeustToReplace Сделал маршрут для генерации документа, и его установки Отредактировал контекст базы данных
490 lines
21 KiB
C#
490 lines
21 KiB
C#
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: "Articles",
|
||
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_Articles", 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: "CausesFoReplace",
|
||
columns: table => new
|
||
{
|
||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||
.Annotation("Sqlite:Autoincrement", true),
|
||
Name = table.Column<string>(type: "TEXT", nullable: false),
|
||
Description = table.Column<string>(type: "TEXT", nullable: false)
|
||
},
|
||
constraints: table =>
|
||
{
|
||
table.PrimaryKey("PK_CausesFoReplace", 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: "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: "RequestsToReplaceCartridge",
|
||
columns: table => new
|
||
{
|
||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||
.Annotation("Sqlite:Autoincrement", true),
|
||
Applocant = table.Column<string>(type: "TEXT", nullable: false),
|
||
LocationName = table.Column<string>(type: "TEXT", nullable: false),
|
||
PrinterInfo = table.Column<string>(type: "TEXT", nullable: false),
|
||
CartridgeInfo = table.Column<string>(type: "TEXT", nullable: false),
|
||
ReplacedCartridgeId = table.Column<int>(type: "INTEGER", nullable: false),
|
||
CauseId = table.Column<int>(type: "INTEGER", nullable: false),
|
||
DateCreateRequest = table.Column<DateOnly>(type: "TEXT", nullable: false),
|
||
Executor = table.Column<string>(type: "TEXT", nullable: true),
|
||
CountCartridgePrinted = table.Column<int>(type: "INTEGER", nullable: true),
|
||
DateAnswerRequest = table.Column<DateOnly>(type: "TEXT", nullable: true),
|
||
SignatureBase64Data = table.Column<string>(type: "TEXT", nullable: true)
|
||
},
|
||
constraints: table =>
|
||
{
|
||
table.PrimaryKey("PK_RequestsToReplaceCartridge", x => x.Id);
|
||
table.ForeignKey(
|
||
name: "FK_RequestsToReplaceCartridge_CausesFoReplace_CauseId",
|
||
column: x => x.CauseId,
|
||
principalTable: "CausesFoReplace",
|
||
principalColumn: "Id",
|
||
onDelete: ReferentialAction.Cascade);
|
||
});
|
||
|
||
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)
|
||
},
|
||
constraints: table =>
|
||
{
|
||
table.PrimaryKey("PK_CartridgeModels", x => x.Id);
|
||
table.ForeignKey(
|
||
name: "FK_CartridgeModels_Manufacturers_ManufacturerId",
|
||
column: x => x.ManufacturerId,
|
||
principalTable: "Manufacturers",
|
||
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)
|
||
},
|
||
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);
|
||
});
|
||
|
||
migrationBuilder.CreateTable(
|
||
name: "ArticleCartridgeModel",
|
||
columns: table => new
|
||
{
|
||
SupportedArticlesId = table.Column<int>(type: "INTEGER", nullable: false),
|
||
SupportedCartridgeModelsId = table.Column<int>(type: "INTEGER", nullable: false)
|
||
},
|
||
constraints: table =>
|
||
{
|
||
table.PrimaryKey("PK_ArticleCartridgeModel", x => new { x.SupportedArticlesId, x.SupportedCartridgeModelsId });
|
||
table.ForeignKey(
|
||
name: "FK_ArticleCartridgeModel_Articles_SupportedArticlesId",
|
||
column: x => x.SupportedArticlesId,
|
||
principalTable: "Articles",
|
||
principalColumn: "Id",
|
||
onDelete: ReferentialAction.Cascade);
|
||
table.ForeignKey(
|
||
name: "FK_ArticleCartridgeModel_CartridgeModels_SupportedCartridgeModelsId",
|
||
column: x => x.SupportedCartridgeModelsId,
|
||
principalTable: "CartridgeModels",
|
||
principalColumn: "Id",
|
||
onDelete: ReferentialAction.Cascade);
|
||
});
|
||
|
||
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: "CausesFoReplace",
|
||
columns: new[] { "Id", "Description", "Name" },
|
||
values: new object[,]
|
||
{
|
||
{ 1, "Картридж истратил свой тоннер и требует заправки.", "Закончился" },
|
||
{ 2, "Картридж работает не корректно, оставляет полосы на распечатанной бумаге. \nТребуется диагностика.", "Полосит" },
|
||
{ 3, "Картридж работает не корректно, тоннер наноситься на бумагу бледно. \nТребуется диагностика.", "Бледнит>" }
|
||
});
|
||
|
||
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_ArticleCartridgeModel_SupportedCartridgeModelsId",
|
||
table: "ArticleCartridgeModel",
|
||
column: "SupportedCartridgeModelsId");
|
||
|
||
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_SupportedArticleId",
|
||
table: "PrinterModels",
|
||
column: "SupportedArticleId",
|
||
unique: true);
|
||
|
||
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");
|
||
|
||
migrationBuilder.CreateIndex(
|
||
name: "IX_RequestsToReplaceCartridge_CauseId",
|
||
table: "RequestsToReplaceCartridge",
|
||
column: "CauseId");
|
||
}
|
||
|
||
/// <inheritdoc />
|
||
protected override void Down(MigrationBuilder migrationBuilder)
|
||
{
|
||
migrationBuilder.DropTable(
|
||
name: "ArticleCartridgeModel");
|
||
|
||
migrationBuilder.DropTable(
|
||
name: "Cartridges");
|
||
|
||
migrationBuilder.DropTable(
|
||
name: "RequestsToReplaceCartridge");
|
||
|
||
migrationBuilder.DropTable(
|
||
name: "CartridgeModels");
|
||
|
||
migrationBuilder.DropTable(
|
||
name: "CartridgeStatuses");
|
||
|
||
migrationBuilder.DropTable(
|
||
name: "Printers");
|
||
|
||
migrationBuilder.DropTable(
|
||
name: "CausesFoReplace");
|
||
|
||
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: "Manufacturers");
|
||
}
|
||
}
|
||
}
|