Class Migration
A migration represents an action or set of actions that need to be done to an object to update it to the game's current version. Migrations are available for a multitude of object types that inhabit a Map, ExportedHousehold or ExportedLot by default. Note that migrations do not have to be registered using Register<T>(IEnumerable<Migration<T>>) when added to a preexisting collection like Migrations or Migrations, but only when a mod adds a custom set of migrations for a custom object type.
public class Migration
- Inheritance
-
Migration
- Derived
-
Migration<T>
- Inherited Members
- Extension Methods
Constructors
Migration(string, MigrationPhase, Func<object, IDictionary<string, JToken>, MigrationResult>)
Creates a new migration with the given settings. To create a migration instance, use Migration<T> instead.
protected Migration(string name, MigrationPhase phase, Func<object, IDictionary<string, JToken>, MigrationResult> apply)
Parameters
name
stringThe name of this migration, which is stored in the save file or exported content once this migration has been applied if Silent is false.
phase
MigrationPhaseThe MigrationPhase that this migration should be applied on. Note that some object types only support the Single phase.
apply
Func<object, IDictionary<string, JToken>, MigrationResult>A function that applies this migration on an object. The passed JSON extension data is additional data that is loaded from disk, but didn't have an appropriate property or field to store it in. This can be useful for migrating objects whose property or field names changed.
Fields
Apply
A function that applies this migration on an object. The passed JSON extension data is additional data that is loaded from disk, but didn't have an appropriate property or field to store it in. This can be useful for migrating objects whose property or field names changed, at which point relevant entries in this dictionary should be removed as part of this function.
public readonly Func<object, IDictionary<string, JToken>, MigrationResult> Apply
Field Value
- Func<object, IDictionary<string, JToken>, MigrationResult>
Migrations
A dictionary that contains all of the migrations for all objects that are currently registered.
public static readonly ReadOnlyDictionary<string, Migration> Migrations
Field Value
Name
The name of this migration, which is stored in the save file or exported content once this migration has been applied if Silent is false.
public readonly string Name
Field Value
Phase
The MigrationPhase that this migration should be applied on. Note that some object types only support the Single phase.
public readonly MigrationPhase Phase
Field Value
Properties
Priority
The priority that this migration should be applied with. A higher priority means that this migration will be applied before migrations with a lower priority. The default value for all migrations is 0.
public int Priority { get; init; }
Property Value
Silent
Whether the migration is silent. A silent migration does not notify the underlying map or exported content that it has been applied, causing its Name not to be stored. This is useful for migrations that can check whether they've been applied some other way, like whether old data has already been removed.
public bool Silent { get; init; }
Property Value
Methods
Register<T>(IEnumerable<Migration<T>>)
Registers a new set of migrations. Note that migrations do not have to be registered using Register<T>(IEnumerable<Migration<T>>) when added to a preexisting collection like Migrations or Migrations, but only when a mod adds a custom set of migrations for a custom object type.
public static void Register<T>(IEnumerable<Migration<T>> migrations)
Parameters
migrations
IEnumerable<Migration<T>>The migrations to register.
Type Parameters
T
The type of the migrations being registered.