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

97 lines
3.5 KiB
C#

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: "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)
},
constraints: table =>
{
table.PrimaryKey("PK_PrinterModels", x => x.id);
});
migrationBuilder.CreateTable(
name: "Printers",
columns: table => new
{
id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
hostname = table.Column<string>(type: "TEXT", nullable: false),
ipAddress = table.Column<string>(type: "TEXT", nullable: false),
locationId = table.Column<int>(type: "INTEGER", nullable: true),
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");
table.ForeignKey(
name: "FK_Printers_PrinterModels_modelId",
column: x => x.modelId,
principalTable: "PrinterModels",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
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: "Printers");
migrationBuilder.DropTable(
name: "Locations");
migrationBuilder.DropTable(
name: "PrinterModels");
}
}
}