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

84 lines
3.1 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: "Cartridges",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Capacity = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Cartridges", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Printers",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
PrinterName = table.Column<string>(type: "TEXT", nullable: false),
IpAddress = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Printers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "CartridgePrinter",
columns: table => new
{
CartridgesHaveId = table.Column<int>(type: "INTEGER", nullable: false),
CartridgesInPrinterId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CartridgePrinter", x => new { x.CartridgesHaveId, x.CartridgesInPrinterId });
table.ForeignKey(
name: "FK_CartridgePrinter_Cartridges_CartridgesHaveId",
column: x => x.CartridgesHaveId,
principalTable: "Cartridges",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_CartridgePrinter_Printers_CartridgesInPrinterId",
column: x => x.CartridgesInPrinterId,
principalTable: "Printers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_CartridgePrinter_CartridgesInPrinterId",
table: "CartridgePrinter",
column: "CartridgesInPrinterId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CartridgePrinter");
migrationBuilder.DropTable(
name: "Cartridges");
migrationBuilder.DropTable(
name: "Printers");
}
}
}