using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace GameDatabase.Migrations { /// public partial class SplitCurrentCostume : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "CurrentBody", table: "UserData", type: "INTEGER", nullable: false, defaultValue: 0u); migrationBuilder.AddColumn( name: "CurrentFace", table: "UserData", type: "INTEGER", nullable: false, defaultValue: 0u); migrationBuilder.AddColumn( name: "CurrentHead", table: "UserData", type: "INTEGER", nullable: false, defaultValue: 0u); migrationBuilder.AddColumn( name: "CurrentKigurumi", table: "UserData", type: "INTEGER", nullable: false, defaultValue: 0u); migrationBuilder.AddColumn( name: "CurrentPuchi", table: "UserData", type: "INTEGER", nullable: false, defaultValue: 0u); // Split CostumeData (json array) into the new fields migrationBuilder.Sql(@" UPDATE UserData SET CurrentKigurumi = COALESCE(json_extract(CostumeData, '$[0]'), 0), CurrentHead = COALESCE(json_extract(CostumeData, '$[1]'), 0), CurrentBody = COALESCE(json_extract(CostumeData, '$[2]'), 0), CurrentFace = COALESCE(json_extract(CostumeData, '$[3]'), 0), CurrentPuchi = COALESCE(json_extract(CostumeData, '$[4]'), 0); "); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropColumn( name: "CurrentBody", table: "UserData"); migrationBuilder.DropColumn( name: "CurrentFace", table: "UserData"); migrationBuilder.DropColumn( name: "CurrentHead", table: "UserData"); migrationBuilder.DropColumn( name: "CurrentKigurumi", table: "UserData"); migrationBuilder.DropColumn( name: "CurrentPuchi", table: "UserData"); } } }