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 = json_extract(CostumeData, '$[0]'), CurrentHead = json_extract(CostumeData, '$[1]'), CurrentBody = json_extract(CostumeData, '$[2]'), CurrentFace = json_extract(CostumeData, '$[3]'), CurrentPuchi = json_extract(CostumeData, '$[4]')"); } /// 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"); } } }