feat(viewer): migration for mypage bg selection
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>
This commit is contained in:
4318
SVSim.Database/Migrations/20260609203145_AddViewerMyPageBgSelection.Designer.cs
generated
Normal file
4318
SVSim.Database/Migrations/20260609203145_AddViewerMyPageBgSelection.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,62 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2600,6 +2600,12 @@ namespace SVSim.Database.Migrations
|
||||
b.Property<DateTime>("LastLogin")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("MyPageBgId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("MyPageBgSelectType")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("ShortUdid")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
@@ -3723,6 +3729,25 @@ namespace SVSim.Database.Migrations
|
||||
|
||||
modelBuilder.Entity("SVSim.Database.Models.Viewer", b =>
|
||||
{
|
||||
b.OwnsMany("SVSim.Database.Models.MyPageBgRotationEntry", "MyPageBgRotation", b1 =>
|
||||
{
|
||||
b1.Property<long>("ViewerId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b1.Property<int>("Slot")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.Property<int>("BgId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.HasKey("ViewerId", "Slot");
|
||||
|
||||
b1.ToTable("ViewerMyPageBgRotation", (string)null);
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("ViewerId");
|
||||
});
|
||||
|
||||
b.OwnsMany("SVSim.Database.Models.OwnedCardEntry", "Cards", b1 =>
|
||||
{
|
||||
b1.Property<long>("ViewerId")
|
||||
@@ -4170,6 +4195,8 @@ namespace SVSim.Database.Migrations
|
||||
b.Navigation("MissionData")
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("MyPageBgRotation");
|
||||
|
||||
b.Navigation("PackOpenCounts");
|
||||
|
||||
b.Navigation("SocialAccountConnections");
|
||||
|
||||
@@ -174,6 +174,7 @@ public class SVSimDbContext : DbContext
|
||||
});
|
||||
modelBuilder.Entity<Viewer>().OwnsMany(v => v.MyPageBgRotation, b =>
|
||||
{
|
||||
b.ToTable("ViewerMyPageBgRotation");
|
||||
b.WithOwner().HasForeignKey("ViewerId");
|
||||
b.HasKey("ViewerId", nameof(MyPageBgRotationEntry.Slot));
|
||||
b.Property(x => x.Slot).ValueGeneratedNever();
|
||||
|
||||
Reference in New Issue
Block a user