using System.Text.Json.Nodes; using SPTarkov.Server.Core.Models.Eft.Profile; namespace SPTarkov.Server.Core.Migration; public abstract class AbstractProfileMigration : IProfileMigration { public virtual string MigrationName { get; } public virtual IEnumerable PrerequisiteMigrations { get; } = []; [Obsolete("Will be removed in the next version of SPT due to this property not being used.")] public abstract string FromVersion { get; } [Obsolete("Will be removed in the next version of SPT due to this property not being used.")] public abstract string ToVersion { get; } public abstract bool CanMigrate(JsonObject profile, IEnumerable previouslyRanMigrations); public virtual JsonObject? Migrate(JsonObject profile) { return profile; } public virtual bool PostMigrate(SptProfile profile) { return true; } protected SemanticVersioning.Version? GetProfileVersion(JsonObject profile) { var versionString = profile["spt"]?["version"]?.GetValue(); if (versionString is null) { return null; } var versionNumber = versionString.Split(' ')[0]; return SemanticVersioning.Version.TryParse(versionNumber, out var version) ? version : null; } }