Files
CartriX/CartriX.Api/Migrations/20260517053100_Init1.cs
T
2026-05-17 23:54:25 +09:00

527 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: "СonnetctionTypes",
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_СonnetctionTypes", x => x.id);
});
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: "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)
},
constraints: table =>
{
table.PrimaryKey("PK_Manufacturers", 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: "PrintTypes",
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_PrintTypes", 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: true),
Articleid = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_CartridgeModels", x => x.id);
table.ForeignKey(
name: "FK_CartridgeModels_Articles_Articleid",
column: x => x.Articleid,
principalTable: "Articles",
principalColumn: "id");
table.ForeignKey(
name: "FK_CartridgeModels_Manufacturers_manufacturerid",
column: x => x.manufacturerid,
principalTable: "Manufacturers",
principalColumn: "id");
});
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),
picturePath = table.Column<string>(type: "TEXT", nullable: true),
manufacturerid = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PrinterModels", x => x.id);
table.ForeignKey(
name: "FK_PrinterModels_Manufacturers_manufacturerid",
column: x => x.manufacturerid,
principalTable: "Manufacturers",
principalColumn: "id");
});
migrationBuilder.CreateTable(
name: "CartridgeArticles",
columns: table => new
{
id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Articleid = table.Column<int>(type: "INTEGER", nullable: false),
CartridgeModelid = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_CartridgeArticles", x => x.id);
table.ForeignKey(
name: "FK_CartridgeArticles_Articles_Articleid",
column: x => x.Articleid,
principalTable: "Articles",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_CartridgeArticles_CartridgeModels_CartridgeModelid",
column: x => x.CartridgeModelid,
principalTable: "CartridgeModels",
principalColumn: "id");
});
migrationBuilder.CreateTable(
name: "ArticlePrinterModel",
columns: table => new
{
Articlesid = table.Column<int>(type: "INTEGER", nullable: false),
PrinterModelid = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ArticlePrinterModel", x => new { x.Articlesid, x.PrinterModelid });
table.ForeignKey(
name: "FK_ArticlePrinterModel_Articles_Articlesid",
column: x => x.Articlesid,
principalTable: "Articles",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ArticlePrinterModel_PrinterModels_PrinterModelid",
column: x => x.PrinterModelid,
principalTable: "PrinterModels",
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),
hostname = table.Column<string>(type: "TEXT", nullable: false),
ipAddress = table.Column<string>(type: "TEXT", nullable: false),
countPrintedAllTime = table.Column<int>(type: "INTEGER", nullable: false),
oidForQueryCountPrintedAllTime = table.Column<string>(type: "TEXT", nullable: true, defaultValue: "1.3.6.1.2.1.43.10.2.1.4.1.1"),
printTypeId = table.Column<int>(type: "INTEGER", nullable: false),
manufacturerid = table.Column<int>(type: "INTEGER", nullable: true),
statusId = table.Column<int>(type: "INTEGER", nullable: false, defaultValue: 1),
connetctionTypeid = table.Column<int>(type: "INTEGER", nullable: false),
locationid = table.Column<int>(type: "INTEGER", nullable: false),
modelid = 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_Manufacturers_manufacturerid",
column: x => x.manufacturerid,
principalTable: "Manufacturers",
principalColumn: "id");
table.ForeignKey(
name: "FK_Printers_PrintTypes_printTypeId",
column: x => x.printTypeId,
principalTable: "PrintTypes",
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_PrinterStatuses_statusId",
column: x => x.statusId,
principalTable: "PrinterStatuses",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Printers_СonnetctionTypes_connetctionTypeid",
column: x => x.connetctionTypeid,
principalTable: "СonnetctionTypes",
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),
maxCountPrint = 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, defaultValue: 2)
},
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: "PrinterArticles",
columns: table => new
{
id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Articleid = table.Column<int>(type: "INTEGER", nullable: false),
Printerid = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PrinterArticles", x => x.id);
table.ForeignKey(
name: "FK_PrinterArticles_Articles_Articleid",
column: x => x.Articleid,
principalTable: "Articles",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PrinterArticles_Printers_Printerid",
column: x => x.Printerid,
principalTable: "Printers",
principalColumn: "id");
});
migrationBuilder.CreateTable(
name: "PrinterCounterRecord",
columns: table => new
{
id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
date = table.Column<DateTime>(type: "TEXT", nullable: false),
printerid = table.Column<int>(type: "INTEGER", nullable: false),
countPrinted = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PrinterCounterRecord", x => x.id);
table.ForeignKey(
name: "FK_PrinterCounterRecord_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, "Installed" },
{ 2, "InStock" },
{ 3, "Refilling" },
{ 4, "InlineRefilling" },
{ 5, "UnderRepair" }
});
migrationBuilder.InsertData(
table: "PrintTypes",
columns: new[] { "id", "name" },
values: new object[,]
{
{ 1, "Laser" },
{ 2, "Inkjet" }
});
migrationBuilder.InsertData(
table: "PrinterStatuses",
columns: new[] { "id", "name" },
values: new object[,]
{
{ 1, "Active" },
{ 2, "Unavailable" },
{ 3, "UnderRepair" }
});
migrationBuilder.InsertData(
table: "СonnetctionTypes",
columns: new[] { "id", "name" },
values: new object[,]
{
{ 1, "Network" },
{ 2, "USB" }
});
migrationBuilder.CreateIndex(
name: "IX_ArticlePrinterModel_PrinterModelid",
table: "ArticlePrinterModel",
column: "PrinterModelid");
migrationBuilder.CreateIndex(
name: "IX_CartridgeArticles_Articleid",
table: "CartridgeArticles",
column: "Articleid");
migrationBuilder.CreateIndex(
name: "IX_CartridgeArticles_CartridgeModelid",
table: "CartridgeArticles",
column: "CartridgeModelid");
migrationBuilder.CreateIndex(
name: "IX_CartridgeModels_Articleid",
table: "CartridgeModels",
column: "Articleid");
migrationBuilder.CreateIndex(
name: "IX_CartridgeModels_manufacturerid",
table: "CartridgeModels",
column: "manufacturerid");
migrationBuilder.CreateIndex(
name: "IX_Cartridges_installedInPrinterid",
table: "Cartridges",
column: "installedInPrinterid");
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_PrinterArticles_Articleid",
table: "PrinterArticles",
column: "Articleid");
migrationBuilder.CreateIndex(
name: "IX_PrinterArticles_Printerid",
table: "PrinterArticles",
column: "Printerid");
migrationBuilder.CreateIndex(
name: "IX_PrinterCounterRecord_printerid",
table: "PrinterCounterRecord",
column: "printerid");
migrationBuilder.CreateIndex(
name: "IX_PrinterModels_manufacturerid",
table: "PrinterModels",
column: "manufacturerid");
migrationBuilder.CreateIndex(
name: "IX_Printers_connetctionTypeid",
table: "Printers",
column: "connetctionTypeid");
migrationBuilder.CreateIndex(
name: "IX_Printers_locationid",
table: "Printers",
column: "locationid");
migrationBuilder.CreateIndex(
name: "IX_Printers_manufacturerid",
table: "Printers",
column: "manufacturerid");
migrationBuilder.CreateIndex(
name: "IX_Printers_modelid",
table: "Printers",
column: "modelid");
migrationBuilder.CreateIndex(
name: "IX_Printers_printTypeId",
table: "Printers",
column: "printTypeId");
migrationBuilder.CreateIndex(
name: "IX_Printers_statusId",
table: "Printers",
column: "statusId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ArticlePrinterModel");
migrationBuilder.DropTable(
name: "CartridgeArticles");
migrationBuilder.DropTable(
name: "Cartridges");
migrationBuilder.DropTable(
name: "PrinterArticles");
migrationBuilder.DropTable(
name: "PrinterCounterRecord");
migrationBuilder.DropTable(
name: "CartridgeModels");
migrationBuilder.DropTable(
name: "CartridgeStatuses");
migrationBuilder.DropTable(
name: "Printers");
migrationBuilder.DropTable(
name: "Articles");
migrationBuilder.DropTable(
name: "Locations");
migrationBuilder.DropTable(
name: "PrintTypes");
migrationBuilder.DropTable(
name: "PrinterModels");
migrationBuilder.DropTable(
name: "PrinterStatuses");
migrationBuilder.DropTable(
name: "СonnetctionTypes");
migrationBuilder.DropTable(
name: "Manufacturers");
}
}
}