Adds AddViewerMyPageBgSelection migration: two int scalars on Viewers (MyPageBgId, MyPageBgSelectType default 0) and ViewerMyPageBgRotation owned table with composite PK (ViewerId, Slot), FK cascade to Viewers. Also adds ToTable(ViewerMyPageBgRotation) to OwnsMany config so EF uses the correct table name instead of defaulting to the entity class. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
63 lines
2.1 KiB
C#
63 lines
2.1 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace SVSim.Database.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddViewerMyPageBgSelection : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "MyPageBgId",
|
|
table: "Viewers",
|
|
type: "integer",
|
|
nullable: false,
|
|
defaultValue: 0);
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "MyPageBgSelectType",
|
|
table: "Viewers",
|
|
type: "integer",
|
|
nullable: false,
|
|
defaultValue: 0);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ViewerMyPageBgRotation",
|
|
columns: table => new
|
|
{
|
|
Slot = table.Column<int>(type: "integer", nullable: false),
|
|
ViewerId = table.Column<long>(type: "bigint", nullable: false),
|
|
BgId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ViewerMyPageBgRotation", x => new { x.ViewerId, x.Slot });
|
|
table.ForeignKey(
|
|
name: "FK_ViewerMyPageBgRotation_Viewers_ViewerId",
|
|
column: x => x.ViewerId,
|
|
principalTable: "Viewers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "ViewerMyPageBgRotation");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "MyPageBgId",
|
|
table: "Viewers");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "MyPageBgSelectType",
|
|
table: "Viewers");
|
|
}
|
|
}
|
|
}
|