mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-05 20:40:55 +00:00
325 lines
14 KiB
C#
325 lines
14 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace CartriX.Api.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Init1 : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "cartridgeArticles",
|
|
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_cartridgeArticles", 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: "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)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_CartridgeModels", x => x.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: "PrintersModelsCartridgeArticles",
|
|
columns: table => new
|
|
{
|
|
Articlesid = table.Column<int>(type: "INTEGER", nullable: false),
|
|
CartridgeModelsid = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_PrintersModelsCartridgeArticles", x => new { x.Articlesid, x.CartridgeModelsid });
|
|
table.ForeignKey(
|
|
name: "FK_PrintersModelsCartridgeArticles_CartridgeModels_CartridgeModelsid",
|
|
column: x => x.CartridgeModelsid,
|
|
principalTable: "CartridgeModels",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_PrintersModelsCartridgeArticles_cartridgeArticles_Articlesid",
|
|
column: x => x.Articlesid,
|
|
principalTable: "cartridgeArticles",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "CartridgeArticlePrinterModel",
|
|
columns: table => new
|
|
{
|
|
PrinterModelsid = table.Column<int>(type: "INTEGER", nullable: false),
|
|
SupportedArticlesid = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_CartridgeArticlePrinterModel", x => new { x.PrinterModelsid, x.SupportedArticlesid });
|
|
table.ForeignKey(
|
|
name: "FK_CartridgeArticlePrinterModel_PrinterModels_PrinterModelsid",
|
|
column: x => x.PrinterModelsid,
|
|
principalTable: "PrinterModels",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_CartridgeArticlePrinterModel_cartridgeArticles_SupportedArticlesid",
|
|
column: x => x.SupportedArticlesid,
|
|
principalTable: "cartridgeArticles",
|
|
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: true),
|
|
ipAddress = table.Column<string>(type: "TEXT", nullable: true),
|
|
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),
|
|
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_PrinterModels_modelid",
|
|
column: x => x.modelid,
|
|
principalTable: "PrinterModels",
|
|
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)
|
|
},
|
|
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_Printers_installedInPrinterid",
|
|
column: x => x.installedInPrinterid,
|
|
principalTable: "Printers",
|
|
principalColumn: "id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "LogPrinters",
|
|
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_LogPrinters", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_LogPrinters_Printers_printerid",
|
|
column: x => x.printerid,
|
|
principalTable: "Printers",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_CartridgeArticlePrinterModel_SupportedArticlesid",
|
|
table: "CartridgeArticlePrinterModel",
|
|
column: "SupportedArticlesid");
|
|
|
|
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_LogPrinters_printerid",
|
|
table: "LogPrinters",
|
|
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_modelid",
|
|
table: "Printers",
|
|
column: "modelid");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Printers_printTypeId",
|
|
table: "Printers",
|
|
column: "printTypeId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PrintersModelsCartridgeArticles_CartridgeModelsid",
|
|
table: "PrintersModelsCartridgeArticles",
|
|
column: "CartridgeModelsid");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "CartridgeArticlePrinterModel");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Cartridges");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "LogPrinters");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "PrintersModelsCartridgeArticles");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Printers");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "CartridgeModels");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "cartridgeArticles");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Locations");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "PrinterModels");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Manufacturers");
|
|
}
|
|
}
|
|
}
|