Files
SPT-Server-Build/Libraries/SPTarkov.Server.Core/Migration/IProfileMigration.cs
T
Jesse 533a7356fd Add new service to handle profile migrations (#468)
* Add new service to handle profile migrations

* Handle various null checks

* Remove unecessary assignments

* Further works on this:

- Loads profiles as JObject's initally, so migration can take place on profiles that don't have proper compatability
- Adds prerequisite migrations, and sorts them after one another

* Throw exception if profile can't be deserialized after migration

* Cleanup & use profile version

* Further migrations work, support 3.10 & 3.11 profiles upgrading to 4.0

* Update parameter name
2025-07-11 13:11:02 +01:00

33 lines
1.4 KiB
C#

using System.Text.Json.Nodes;
using SPTarkov.Server.Core.Models.Eft.Profile;
namespace SPTarkov.Server.Core.Migration
{
public interface IProfileMigration
{
/// <summary>
/// Allows for adding checks if the profile in question can migrate
/// </summary>
/// <param name="profile">The profile to check</param>
/// <returns>Returns true if the profile can migrate, returns false if not</returns>
public bool CanMigrate(
JsonObject profile,
IEnumerable<IProfileMigration> previouslyRanMigrations
);
/// <summary>
/// Migrate the profile, this should be used to handle and fix old data that has been removed from the <see cref="SptProfile"/> record
/// or a general incompatibility due to different typing
/// </summary>
/// <param name="profile">The profile to migrate</param>
/// <returns>Returns the migrated profile on success, or null if it failed</returns>
public JsonObject? Migrate(JsonObject profile);
/// <summary>
/// Handles post migration of the profile, this can be used to fill new types with (old) data gotten from <see cref="Migrate"/>
/// </summary>
/// <returns>Should return true if successful, should return false if not</returns>
public bool PostMigrate(SptProfile profile);
}
}