Files
CartriX/CartriX.Api/Migrations/20260519095730_ChangePrinter.cs
T
2026-05-22 01:21:04 +09:00

180 lines
6.1 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CartriX.Api.Migrations
{
/// <inheritdoc />
public partial class ChangePrinter : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_PrinterModels_Manufacturers_manufacturerid",
table: "PrinterModels");
migrationBuilder.DropForeignKey(
name: "FK_Printers_ConnectionTypes_connetctionTypeid",
table: "Printers");
migrationBuilder.DropForeignKey(
name: "FK_Printers_Manufacturers_manufacturerid",
table: "Printers");
migrationBuilder.DropIndex(
name: "IX_Printers_manufacturerid",
table: "Printers");
migrationBuilder.DropColumn(
name: "manufacturerid",
table: "Printers");
migrationBuilder.RenameColumn(
name: "connetctionTypeid",
table: "Printers",
newName: "connetctionTypeId");
migrationBuilder.RenameIndex(
name: "IX_Printers_connetctionTypeid",
table: "Printers",
newName: "IX_Printers_connetctionTypeId");
migrationBuilder.AlterColumn<string>(
name: "ipAddress",
table: "Printers",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT");
migrationBuilder.AlterColumn<string>(
name: "hostname",
table: "Printers",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT");
migrationBuilder.AlterColumn<int>(
name: "manufacturerid",
table: "PrinterModels",
type: "INTEGER",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.InsertData(
table: "Manufacturers",
columns: new[] { "id", "name" },
values: new object[] { 1, "Unknown" });
migrationBuilder.AddForeignKey(
name: "FK_PrinterModels_Manufacturers_manufacturerid",
table: "PrinterModels",
column: "manufacturerid",
principalTable: "Manufacturers",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Printers_ConnectionTypes_connetctionTypeId",
table: "Printers",
column: "connetctionTypeId",
principalTable: "ConnectionTypes",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_PrinterModels_Manufacturers_manufacturerid",
table: "PrinterModels");
migrationBuilder.DropForeignKey(
name: "FK_Printers_ConnectionTypes_connetctionTypeId",
table: "Printers");
migrationBuilder.DeleteData(
table: "Manufacturers",
keyColumn: "id",
keyValue: 1);
migrationBuilder.RenameColumn(
name: "connetctionTypeId",
table: "Printers",
newName: "connetctionTypeid");
migrationBuilder.RenameIndex(
name: "IX_Printers_connetctionTypeId",
table: "Printers",
newName: "IX_Printers_connetctionTypeid");
migrationBuilder.AlterColumn<string>(
name: "ipAddress",
table: "Printers",
type: "TEXT",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "hostname",
table: "Printers",
type: "TEXT",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AddColumn<int>(
name: "manufacturerid",
table: "Printers",
type: "INTEGER",
nullable: true);
migrationBuilder.AlterColumn<int>(
name: "manufacturerid",
table: "PrinterModels",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER");
migrationBuilder.CreateIndex(
name: "IX_Printers_manufacturerid",
table: "Printers",
column: "manufacturerid");
migrationBuilder.AddForeignKey(
name: "FK_PrinterModels_Manufacturers_manufacturerid",
table: "PrinterModels",
column: "manufacturerid",
principalTable: "Manufacturers",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "FK_Printers_ConnectionTypes_connetctionTypeid",
table: "Printers",
column: "connetctionTypeid",
principalTable: "ConnectionTypes",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Printers_Manufacturers_manufacturerid",
table: "Printers",
column: "manufacturerid",
principalTable: "Manufacturers",
principalColumn: "id");
}
}
}