Update profile migration code
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using System.Text.Json.Nodes;
|
||||
using SPTarkov.DI.Annotations;
|
||||
|
||||
namespace SPTarkov.Server.Core.Migration.Migrations;
|
||||
|
||||
[Injectable]
|
||||
public class RemoveVitaltyFromProfile : AbstractProfileMigration
|
||||
{
|
||||
public override string FromVersion
|
||||
{
|
||||
get { return "~4.0"; }
|
||||
}
|
||||
|
||||
public override string ToVersion
|
||||
{
|
||||
get { return "~4.0"; }
|
||||
}
|
||||
|
||||
public override string MigrationName
|
||||
{
|
||||
get { return "RemoveVitaltyFromProfile400"; }
|
||||
}
|
||||
|
||||
public override IEnumerable<Type> PrerequisiteMigrations
|
||||
{
|
||||
get { return [typeof(ThreeElevenToFourZero)]; }
|
||||
}
|
||||
|
||||
public override bool CanMigrate(JsonObject profile, IEnumerable<IProfileMigration> previouslyRanMigrations)
|
||||
{
|
||||
return profile["vitality"] is not null;
|
||||
}
|
||||
|
||||
public override JsonObject? Migrate(JsonObject profile)
|
||||
{
|
||||
profile.Remove("vitality");
|
||||
|
||||
return base.Migrate(profile);
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,14 @@ public class ProfileValidatorService(
|
||||
sptReadyProfile.SptData.Migrations = [];
|
||||
}
|
||||
|
||||
sptReadyProfile.SptData.Migrations.Add(ranMigration.MigrationName, timeUtil.GetTimeStamp());
|
||||
if (!sptReadyProfile.SptData.Migrations.ContainsKey(ranMigration.MigrationName))
|
||||
{
|
||||
sptReadyProfile.SptData.Migrations.Add(ranMigration.MigrationName, timeUtil.GetTimeStamp());
|
||||
}
|
||||
else
|
||||
{
|
||||
sptReadyProfile.SptData.Migrations[ranMigration.MigrationName] = timeUtil.GetTimeStamp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user