From 98fd8ce6ec0dcac5f3d13e96bfb4c5790b85722f Mon Sep 17 00:00:00 2001
From: S-Sebb <794194678@qq.com>
Date: Sun, 26 May 2024 21:34:50 +0100
Subject: [PATCH] Migration fixes
---
...lockedUraSongIdListToUserDatum.Designer.cs | 491 ------------------
...355_AddUnlockedUraSongIdListToUserDatum.cs | 22 -
.../20240309102758_SeparateTokens.cs | 7 +-
.../20240317153533_SplitCurrentCostume.cs | 11 +-
.../20240317163817_SplitDifficultyArrays.cs | 14 +-
5 files changed, 20 insertions(+), 525 deletions(-)
delete mode 100644 GameDatabase/Migrations/20240203182355_AddUnlockedUraSongIdListToUserDatum.Designer.cs
delete mode 100644 GameDatabase/Migrations/20240203182355_AddUnlockedUraSongIdListToUserDatum.cs
diff --git a/GameDatabase/Migrations/20240203182355_AddUnlockedUraSongIdListToUserDatum.Designer.cs b/GameDatabase/Migrations/20240203182355_AddUnlockedUraSongIdListToUserDatum.Designer.cs
deleted file mode 100644
index 98dfeb4..0000000
--- a/GameDatabase/Migrations/20240203182355_AddUnlockedUraSongIdListToUserDatum.Designer.cs
+++ /dev/null
@@ -1,491 +0,0 @@
-//
-using System;
-using GameDatabase.Context;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace GameDatabase.Migrations
-{
- [DbContext(typeof(TaikoDbContext))]
- [Migration("20240203182355_AddUnlockedUraSongIdListToUserDatum")]
- partial class AddUnlockedUraSongIdListToUserDatum
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder.HasAnnotation("ProductVersion", "8.0.0-rc.2.23480.1");
-
- modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
- {
- b.Property("Baid")
- .HasColumnType("INTEGER");
-
- b.Property("SongId")
- .HasColumnType("INTEGER");
-
- b.Property("Difficulty")
- .HasColumnType("INTEGER");
-
- b.Property("IsWin")
- .HasColumnType("INTEGER");
-
- b.HasKey("Baid", "SongId", "Difficulty");
-
- b.ToTable("AiScoreData");
- });
-
- modelBuilder.Entity("GameDatabase.Entities.AiSectionScoreDatum", b =>
- {
- b.Property("Baid")
- .HasColumnType("INTEGER");
-
- b.Property("SongId")
- .HasColumnType("INTEGER");
-
- b.Property("Difficulty")
- .HasColumnType("INTEGER");
-
- b.Property("SectionIndex")
- .HasColumnType("INTEGER");
-
- b.Property("Crown")
- .HasColumnType("INTEGER");
-
- b.Property("DrumrollCount")
- .HasColumnType("INTEGER");
-
- b.Property("GoodCount")
- .HasColumnType("INTEGER");
-
- b.Property("IsWin")
- .HasColumnType("INTEGER");
-
- b.Property("MissCount")
- .HasColumnType("INTEGER");
-
- b.Property("OkCount")
- .HasColumnType("INTEGER");
-
- b.Property("Score")
- .HasColumnType("INTEGER");
-
- b.HasKey("Baid", "SongId", "Difficulty", "SectionIndex");
-
- b.ToTable("AiSectionScoreData");
- });
-
- modelBuilder.Entity("GameDatabase.Entities.Card", b =>
- {
- b.Property("AccessCode")
- .HasColumnType("TEXT");
-
- b.Property("Baid")
- .HasColumnType("INTEGER");
-
- b.HasKey("AccessCode");
-
- b.HasIndex("Baid");
-
- b.ToTable("Card", (string)null);
- });
-
- modelBuilder.Entity("GameDatabase.Entities.Credential", b =>
- {
- b.Property("Baid")
- .HasColumnType("INTEGER");
-
- b.Property("Password")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("Salt")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.HasKey("Baid");
-
- b.ToTable("Credential", (string)null);
- });
-
- modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
- {
- b.Property("Baid")
- .HasColumnType("INTEGER");
-
- b.Property("DanId")
- .HasColumnType("INTEGER");
-
- b.Property("DanType")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER")
- .HasDefaultValue(1);
-
- b.Property("ArrivalSongCount")
- .HasColumnType("INTEGER");
-
- b.Property("ClearState")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER")
- .HasDefaultValue(0u);
-
- b.Property("ComboCountTotal")
- .HasColumnType("INTEGER");
-
- b.Property("SoulGaugeTotal")
- .HasColumnType("INTEGER");
-
- b.HasKey("Baid", "DanId", "DanType");
-
- b.ToTable("DanScoreData");
- });
-
- modelBuilder.Entity("GameDatabase.Entities.DanStageScoreDatum", b =>
- {
- b.Property("Baid")
- .HasColumnType("INTEGER");
-
- b.Property("DanId")
- .HasColumnType("INTEGER");
-
- b.Property("DanType")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER")
- .HasDefaultValue(1);
-
- b.Property("SongNumber")
- .HasColumnType("INTEGER");
-
- b.Property("BadCount")
- .HasColumnType("INTEGER");
-
- b.Property("ComboCount")
- .HasColumnType("INTEGER");
-
- b.Property("DrumrollCount")
- .HasColumnType("INTEGER");
-
- b.Property("GoodCount")
- .HasColumnType("INTEGER");
-
- b.Property("HighScore")
- .HasColumnType("INTEGER");
-
- b.Property("OkCount")
- .HasColumnType("INTEGER");
-
- b.Property("PlayScore")
- .HasColumnType("INTEGER");
-
- b.Property("TotalHitCount")
- .HasColumnType("INTEGER");
-
- b.HasKey("Baid", "DanId", "DanType", "SongNumber");
-
- b.ToTable("DanStageScoreData");
- });
-
- modelBuilder.Entity("GameDatabase.Entities.SongBestDatum", b =>
- {
- b.Property("Baid")
- .HasColumnType("INTEGER");
-
- b.Property("SongId")
- .HasColumnType("INTEGER");
-
- b.Property("Difficulty")
- .HasColumnType("INTEGER");
-
- b.Property("BestCrown")
- .HasColumnType("INTEGER");
-
- b.Property("BestRate")
- .HasColumnType("INTEGER");
-
- b.Property("BestScore")
- .HasColumnType("INTEGER");
-
- b.Property("BestScoreRank")
- .HasColumnType("INTEGER");
-
- b.HasKey("Baid", "SongId", "Difficulty");
-
- b.ToTable("SongBestData");
- });
-
- modelBuilder.Entity("GameDatabase.Entities.SongPlayDatum", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("Baid")
- .HasColumnType("INTEGER");
-
- b.Property("ComboCount")
- .HasColumnType("INTEGER");
-
- b.Property("Crown")
- .HasColumnType("INTEGER");
-
- b.Property("Difficulty")
- .HasColumnType("INTEGER");
-
- b.Property("DrumrollCount")
- .HasColumnType("INTEGER");
-
- b.Property("GoodCount")
- .HasColumnType("INTEGER");
-
- b.Property("HitCount")
- .HasColumnType("INTEGER");
-
- b.Property("MissCount")
- .HasColumnType("INTEGER");
-
- b.Property("OkCount")
- .HasColumnType("INTEGER");
-
- b.Property("PlayTime")
- .HasColumnType("datetime");
-
- b.Property("Score")
- .HasColumnType("INTEGER");
-
- b.Property("ScoreRank")
- .HasColumnType("INTEGER");
-
- b.Property("ScoreRate")
- .HasColumnType("INTEGER");
-
- b.Property("Skipped")
- .HasColumnType("INTEGER");
-
- b.Property("SongId")
- .HasColumnType("INTEGER");
-
- b.Property("SongNumber")
- .HasColumnType("INTEGER");
-
- b.HasKey("Id");
-
- b.HasIndex("Baid");
-
- b.ToTable("SongPlayData");
- });
-
- modelBuilder.Entity("GameDatabase.Entities.UserDatum", b =>
- {
- b.Property("Baid")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("AchievementDisplayDifficulty")
- .HasColumnType("INTEGER");
-
- b.Property("AiWinCount")
- .HasColumnType("INTEGER");
-
- b.Property("ColorBody")
- .HasColumnType("INTEGER");
-
- b.Property("ColorFace")
- .HasColumnType("INTEGER");
-
- b.Property("ColorLimb")
- .HasColumnType("INTEGER");
-
- b.Property("CostumeData")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("CostumeFlgArray")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("DifficultyPlayedArray")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("DifficultySettingArray")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("DisplayAchievement")
- .HasColumnType("INTEGER");
-
- b.Property("DisplayDan")
- .HasColumnType("INTEGER");
-
- b.Property("FavoriteSongsArray")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("GenericInfoFlgArray")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("IsAdmin")
- .HasColumnType("INTEGER");
-
- b.Property("IsSkipOn")
- .HasColumnType("INTEGER");
-
- b.Property("IsVoiceOn")
- .HasColumnType("INTEGER");
-
- b.Property("LastPlayDatetime")
- .HasColumnType("datetime");
-
- b.Property("LastPlayMode")
- .HasColumnType("INTEGER");
-
- b.Property("MyDonName")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("MyDonNameLanguage")
- .HasColumnType("INTEGER");
-
- b.Property("NotesPosition")
- .HasColumnType("INTEGER");
-
- b.Property("OptionSetting")
- .HasColumnType("INTEGER");
-
- b.Property("SelectedToneId")
- .HasColumnType("INTEGER");
-
- b.Property("Title")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("TitleFlgArray")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("TitlePlateId")
- .HasColumnType("INTEGER");
-
- b.Property("TokenCountDict")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("ToneFlgArray")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("UnlockedSongIdList")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.HasKey("Baid");
-
- b.ToTable("UserData");
- });
-
- modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
- {
- b.HasOne("GameDatabase.Entities.UserDatum", "Ba")
- .WithMany()
- .HasForeignKey("Baid")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Ba");
- });
-
- modelBuilder.Entity("GameDatabase.Entities.AiSectionScoreDatum", b =>
- {
- b.HasOne("GameDatabase.Entities.AiScoreDatum", "Parent")
- .WithMany("AiSectionScoreData")
- .HasForeignKey("Baid", "SongId", "Difficulty")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Parent");
- });
-
- modelBuilder.Entity("GameDatabase.Entities.Card", b =>
- {
- b.HasOne("GameDatabase.Entities.UserDatum", "Ba")
- .WithMany()
- .HasForeignKey("Baid")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Ba");
- });
-
- modelBuilder.Entity("GameDatabase.Entities.Credential", b =>
- {
- b.HasOne("GameDatabase.Entities.UserDatum", "Ba")
- .WithMany()
- .HasForeignKey("Baid")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Ba");
- });
-
- modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
- {
- b.HasOne("GameDatabase.Entities.UserDatum", "Ba")
- .WithMany()
- .HasForeignKey("Baid")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Ba");
- });
-
- modelBuilder.Entity("GameDatabase.Entities.DanStageScoreDatum", b =>
- {
- b.HasOne("GameDatabase.Entities.DanScoreDatum", "Parent")
- .WithMany("DanStageScoreData")
- .HasForeignKey("Baid", "DanId", "DanType")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Parent");
- });
-
- modelBuilder.Entity("GameDatabase.Entities.SongBestDatum", b =>
- {
- b.HasOne("GameDatabase.Entities.UserDatum", "Ba")
- .WithMany()
- .HasForeignKey("Baid")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Ba");
- });
-
- modelBuilder.Entity("GameDatabase.Entities.SongPlayDatum", b =>
- {
- b.HasOne("GameDatabase.Entities.UserDatum", "Ba")
- .WithMany()
- .HasForeignKey("Baid")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Ba");
- });
-
- modelBuilder.Entity("GameDatabase.Entities.AiScoreDatum", b =>
- {
- b.Navigation("AiSectionScoreData");
- });
-
- modelBuilder.Entity("GameDatabase.Entities.DanScoreDatum", b =>
- {
- b.Navigation("DanStageScoreData");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/GameDatabase/Migrations/20240203182355_AddUnlockedUraSongIdListToUserDatum.cs b/GameDatabase/Migrations/20240203182355_AddUnlockedUraSongIdListToUserDatum.cs
deleted file mode 100644
index 0fbbe6a..0000000
--- a/GameDatabase/Migrations/20240203182355_AddUnlockedUraSongIdListToUserDatum.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace GameDatabase.Migrations
-{
- ///
- public partial class AddUnlockedUraSongIdListToUserDatum : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
-
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
-
- }
- }
-}
diff --git a/GameDatabase/Migrations/20240309102758_SeparateTokens.cs b/GameDatabase/Migrations/20240309102758_SeparateTokens.cs
index 8b7e718..ff97edc 100644
--- a/GameDatabase/Migrations/20240309102758_SeparateTokens.cs
+++ b/GameDatabase/Migrations/20240309102758_SeparateTokens.cs
@@ -40,7 +40,12 @@ namespace GameDatabase.Migrations
});
foreach (var (baid, tokenCountDict) in tokenJsons)
{
- var tokenDict = JsonSerializer.Deserialize>(tokenCountDict);
+ Dictionary tokenDict;
+ if (string.IsNullOrEmpty(tokenCountDict)) {
+ tokenDict = new();
+ } else {
+ tokenDict = JsonSerializer.Deserialize>(tokenCountDict);
+ }
foreach (var (key, value) in tokenDict)
{
migrationBuilder.InsertData(
diff --git a/GameDatabase/Migrations/20240317153533_SplitCurrentCostume.cs b/GameDatabase/Migrations/20240317153533_SplitCurrentCostume.cs
index f355a1f..b12891e 100644
--- a/GameDatabase/Migrations/20240317153533_SplitCurrentCostume.cs
+++ b/GameDatabase/Migrations/20240317153533_SplitCurrentCostume.cs
@@ -47,11 +47,12 @@ namespace GameDatabase.Migrations
// 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]')");
+ 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);
+ ");
}
///
diff --git a/GameDatabase/Migrations/20240317163817_SplitDifficultyArrays.cs b/GameDatabase/Migrations/20240317163817_SplitDifficultyArrays.cs
index 539d611..4ddf7b1 100644
--- a/GameDatabase/Migrations/20240317163817_SplitDifficultyArrays.cs
+++ b/GameDatabase/Migrations/20240317163817_SplitDifficultyArrays.cs
@@ -52,15 +52,17 @@ namespace GameDatabase.Migrations
nullable: false,
defaultValue: 0u);
+
// Extract from json arrays
migrationBuilder.Sql(@"
UPDATE UserData
- SET DifficultyPlayedCourse = json_extract(DifficultyPlayedArray, '$[0]'),
- DifficultyPlayedStar = json_extract(DifficultyPlayedArray, '$[1]'),
- DifficultyPlayedSort = json_extract(DifficultyPlayedArray, '$[2]') ,
- DifficultySettingCourse = json_extract(DifficultySettingArray, '$[0]'),
- DifficultySettingStar = json_extract(DifficultySettingArray, '$[1]'),
- DifficultySettingSort = json_extract(DifficultySettingArray, '$[2]');
+ SET
+ DifficultyPlayedCourse = COALESCE(json_extract(DifficultyPlayedArray, '$[0]'), 0),
+ DifficultyPlayedStar = COALESCE(json_extract(DifficultyPlayedArray, '$[1]'), 0),
+ DifficultyPlayedSort = COALESCE(json_extract(DifficultyPlayedArray, '$[2]'), 0),
+ DifficultySettingCourse = COALESCE(json_extract(DifficultySettingArray, '$[0]'), 0),
+ DifficultySettingStar = COALESCE(json_extract(DifficultySettingArray, '$[1]'), 0),
+ DifficultySettingSort = COALESCE(json_extract(DifficultySettingArray, '$[2]'), 0);
");
}