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

182 lines
6.9 KiB
C#

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: "CartridgeModels",
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_CartridgeModels", 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: "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)
},
constraints: table =>
{
table.PrimaryKey("PK_PrinterModels", x => x.id);
});
migrationBuilder.CreateTable(
name: "PrinterTypes",
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_PrinterTypes", x => x.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),
hostname = table.Column<string>(type: "TEXT", nullable: false),
ipAddress = table.Column<string>(type: "TEXT", 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),
countPrinted = table.Column<int>(type: "INTEGER", nullable: false),
installedInPrinterid = table.Column<int>(type: "INTEGER", nullable: true)
},
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.InsertData(
table: "PrinterTypes",
columns: new[] { "id", "name" },
values: new object[,]
{
{ 1, "Laser" },
{ 2, "Inkjet" }
});
migrationBuilder.CreateIndex(
name: "IX_Cartridges_installedInPrinterid",
table: "Cartridges",
column: "installedInPrinterid");
migrationBuilder.CreateIndex(
name: "IX_Cartridges_modelid",
table: "Cartridges",
column: "modelid");
migrationBuilder.CreateIndex(
name: "IX_Locations_name",
table: "Locations",
column: "name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Printers_locationid",
table: "Printers",
column: "locationid");
migrationBuilder.CreateIndex(
name: "IX_Printers_modelid",
table: "Printers",
column: "modelid");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Cartridges");
migrationBuilder.DropTable(
name: "PrinterTypes");
migrationBuilder.DropTable(
name: "CartridgeModels");
migrationBuilder.DropTable(
name: "Printers");
migrationBuilder.DropTable(
name: "Locations");
migrationBuilder.DropTable(
name: "PrinterModels");
}
}
}