1
0
mirror of https://github.com/ppy/osu synced 2025-03-31 15:47:40 +00:00

Separate out startup tasks to ensure they run after migrations

This commit is contained in:
Dean Herbert 2017-08-01 10:08:05 +09:00
parent 404497fa10
commit c060d32765
3 changed files with 30 additions and 6 deletions

View File

@ -52,7 +52,11 @@ namespace osu.Game.Beatmaps
Connection.CreateTable<BeatmapSetInfo>();
Connection.CreateTable<BeatmapSetFileInfo>();
Connection.CreateTable<BeatmapInfo>();
}
protected override void StartupTasks()
{
base.StartupTasks();
cleanupPendingDeletions();
}
@ -60,12 +64,12 @@ namespace osu.Game.Beatmaps
/// Perform migrations between two store versions.
/// </summary>
/// <param name="currentVersion">The current store version. This will be zero on a fresh database initialisation.</param>
/// <param name="newVersion">The target version which we are migrating to (equal to the current <see cref="StoreVersion"/>).</param>
protected override void PerformMigration(int currentVersion, int newVersion)
/// <param name="targetVersion">The target version which we are migrating to (equal to the current <see cref="StoreVersion"/>).</param>
protected override void PerformMigration(int currentVersion, int targetVersion)
{
base.PerformMigration(currentVersion, newVersion);
base.PerformMigration(currentVersion, targetVersion);
while (currentVersion++ < newVersion)
while (currentVersion++ < targetVersion)
{
switch (currentVersion)
{

View File

@ -51,14 +51,30 @@ namespace osu.Game.Database
PerformMigration(reportedVersion.Version, reportedVersion.Version = StoreVersion);
Connection.InsertOrReplace(reportedVersion);
StartupTasks();
}
protected virtual void PerformMigration(int currentVersion, int newVersion)
/// <summary>
/// Called when the database version of this store doesn't match the local version.
/// Any manual migration operations should be performed in this.
/// </summary>
/// <param name="currentVersion">The current store version. This will be zero on a fresh database initialisation.</param>
/// <param name="targetVersion">The target version which we are migrating to (equal to the current <see cref="StoreVersion"/>).</param>
protected virtual void PerformMigration(int currentVersion, int targetVersion)
{
}
/// <summary>
/// Prepare this database for use.
/// Perform any common startup tasks. Runs after <see cref="Prepare(bool)"/> and <see cref="PerformMigration(int, int)"/>.
/// </summary>
protected virtual void StartupTasks()
{
}
/// <summary>
/// Prepare this database for use. Tables should be created here.
/// </summary>
protected abstract void Prepare(bool reset = false);

View File

@ -38,7 +38,11 @@ namespace osu.Game.IO
Connection.DropTable<FileInfo>();
Connection.CreateTable<FileInfo>();
}
protected override void StartupTasks()
{
base.StartupTasks();
deletePending();
}