using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace CartriX.Api.Migrations
{
///
public partial class Init1 : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CartridgeModelFamily",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CartridgeModelFamily", x => x.Id);
});
migrationBuilder.CreateTable(
name: "CartridgeStatuses",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CartridgeStatuses", x => x.Id);
});
migrationBuilder.CreateTable(
name: "CausesFoReplace",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column(type: "TEXT", nullable: false),
Description = table.Column(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CausesFoReplace", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Locations",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Locations", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Manufacturers",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column(type: "TEXT", nullable: false),
picturePath = table.Column(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Manufacturers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "PrinterConnetctionTypes",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PrinterConnetctionTypes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "PrinterPrintTypes",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PrinterPrintTypes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "PrinterStatuses",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PrinterStatuses", x => x.Id);
});
migrationBuilder.CreateTable(
name: "RequestsToReplaceCartridge",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Applocant = table.Column(type: "TEXT", nullable: false),
LocationName = table.Column(type: "TEXT", nullable: false),
PrinterInfo = table.Column(type: "TEXT", nullable: false),
CartridgeInfo = table.Column(type: "TEXT", nullable: false),
DateCreateRequest = table.Column(type: "TEXT", nullable: false),
Executor = table.Column(type: "TEXT", nullable: true),
CountCartridgePrinted = table.Column(type: "INTEGER", nullable: true),
ReplacedCartridgeId = table.Column(type: "INTEGER", nullable: false),
CauseId = table.Column(type: "INTEGER", nullable: false),
DateAnswerRequest = table.Column(type: "TEXT", nullable: true),
SignatureBase64Data = table.Column(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(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column(type: "TEXT", nullable: false),
ManufacturerId = table.Column(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(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column(type: "TEXT", nullable: false),
ManufacturerId = table.Column(type: "INTEGER", nullable: false),
PicturePath = table.Column(type: "TEXT", nullable: true),
SupportedArticleId = table.Column(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PrinterModels", x => x.Id);
table.ForeignKey(
name: "FK_PrinterModels_CartridgeModelFamily_SupportedArticleId",
column: x => x.SupportedArticleId,
principalTable: "CartridgeModelFamily",
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: "CartridgeModelCartridgeModelFamily",
columns: table => new
{
CartridgeModelsId = table.Column(type: "INTEGER", nullable: false),
SupportedFamiliesId = table.Column(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CartridgeModelCartridgeModelFamily", x => new { x.CartridgeModelsId, x.SupportedFamiliesId });
table.ForeignKey(
name: "FK_CartridgeModelCartridgeModelFamily_CartridgeModelFamily_SupportedFamiliesId",
column: x => x.SupportedFamiliesId,
principalTable: "CartridgeModelFamily",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_CartridgeModelCartridgeModelFamily_CartridgeModels_CartridgeModelsId",
column: x => x.CartridgeModelsId,
principalTable: "CartridgeModels",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Printers",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column(type: "TEXT", nullable: false),
IpAddressOrHostname = table.Column(type: "TEXT", nullable: true),
CountPrintedAllTime = table.Column(type: "INTEGER", nullable: false),
OidForQueryCountPrintedAllTime = table.Column(type: "TEXT", nullable: true),
PrintTypeId = table.Column(type: "INTEGER", nullable: false),
ModelId = table.Column(type: "INTEGER", nullable: false),
StatusId = table.Column(type: "INTEGER", nullable: false),
PrinterConnetctionTypeId = table.Column(type: "INTEGER", nullable: false),
LocationId = table.Column(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_StatusId",
column: x => x.StatusId,
principalTable: "PrinterStatuses",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Cartridges",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
ModelId = table.Column(type: "INTEGER", nullable: false),
Volume = table.Column(type: "INTEGER", nullable: false),
DateLastFilling = table.Column(type: "TEXT", nullable: true),
CountPrinted = table.Column(type: "INTEGER", nullable: false),
InstalledInPrinterId = table.Column(type: "INTEGER", nullable: true),
StatusId = table.Column(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.CreateTable(
name: "RecordPrintedPages",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Date = table.Column(type: "TEXT", nullable: false),
PrinterId = table.Column(type: "INTEGER", nullable: false),
CounntPrinted = table.Column(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RecordPrintedPages", x => x.Id);
table.ForeignKey(
name: "FK_RecordPrintedPages_Printers_PrinterId",
column: x => x.PrinterId,
principalTable: "Printers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
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_CartridgeModelCartridgeModelFamily_SupportedFamiliesId",
table: "CartridgeModelCartridgeModelFamily",
column: "SupportedFamiliesId");
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_PrintTypeId",
table: "Printers",
column: "PrintTypeId");
migrationBuilder.CreateIndex(
name: "IX_Printers_StatusId",
table: "Printers",
column: "StatusId");
migrationBuilder.CreateIndex(
name: "IX_RecordPrintedPages_PrinterId",
table: "RecordPrintedPages",
column: "PrinterId");
migrationBuilder.CreateIndex(
name: "IX_RequestsToReplaceCartridge_CauseId",
table: "RequestsToReplaceCartridge",
column: "CauseId");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CartridgeModelCartridgeModelFamily");
migrationBuilder.DropTable(
name: "Cartridges");
migrationBuilder.DropTable(
name: "RecordPrintedPages");
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: "CartridgeModelFamily");
migrationBuilder.DropTable(
name: "Manufacturers");
}
}
}