#pragma warning disable CA1019 // Define accessors for attribute arguments
using System;
using System.Globalization;
using Jellyfin.Server.Migrations.Stages;
namespace Jellyfin.Server.Migrations;
///
/// Declares an class as an migration with its set metadata.
///
[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
public sealed class JellyfinMigrationAttribute : Attribute
{
///
/// Initializes a new instance of the class.
///
/// The ordering this migration should be applied to. Must be a valid DateTime ISO8601 formatted string.
/// The name of this Migration.
#pragma warning disable CS0618 // Type or member is obsolete
public JellyfinMigrationAttribute(string order, string name) : this(order, name, null)
#pragma warning restore CS0618 // Type or member is obsolete
{
}
///
/// Initializes a new instance of the class for legacy migrations.
///
/// The ordering this migration should be applied to. Must be a valid DateTime ISO8601 formatted string.
/// The name of this Migration.
/// [ONLY FOR LEGACY MIGRATIONS]The unique key of this migration. Must be a valid Guid formatted string.
[Obsolete("This Constructor should only be used for Legacy migrations. Use the (Order,Name) one for all new ones instead.")]
public JellyfinMigrationAttribute(string order, string name, string? key)
{
Order = DateTime.Parse(order, CultureInfo.InvariantCulture);
Name = name;
Stage = JellyfinMigrationStageTypes.AppInitialisation;
if (key is not null)
{
Key = Guid.Parse(key);
}
}
///
/// Gets or Sets a value indicating whether the annoated migration should be executed on a fresh install.
///
public bool RunMigrationOnSetup { get; set; }
///
/// Gets or Sets the stage the annoated migration should be executed at. Defaults to .
///
public JellyfinMigrationStageTypes Stage { get; set; } = JellyfinMigrationStageTypes.CoreInitialisation;
///
/// Gets the ordering of the migration.
///
public DateTime Order { get; }
///
/// Gets the name of the migration.
///
public string Name { get; }
///
/// Gets the Legacy Key of the migration. Not required for new Migrations.
///
public Guid? Key { get; }
}