| | | 1 | | #pragma warning disable CA1019 // Define accessors for attribute arguments |
| | | 2 | | |
| | | 3 | | using System; |
| | | 4 | | using System.Globalization; |
| | | 5 | | using Jellyfin.Server.Migrations.Stages; |
| | | 6 | | |
| | | 7 | | namespace Jellyfin.Server.Migrations; |
| | | 8 | | |
| | | 9 | | /// <summary> |
| | | 10 | | /// Declares an class as an migration with its set metadata. |
| | | 11 | | /// </summary> |
| | | 12 | | [AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = false)] |
| | | 13 | | public sealed class JellyfinMigrationAttribute : Attribute |
| | | 14 | | { |
| | | 15 | | /// <summary> |
| | | 16 | | /// Initializes a new instance of the <see cref="JellyfinMigrationAttribute"/> class. |
| | | 17 | | /// </summary> |
| | | 18 | | /// <param name="order">The ordering this migration should be applied to. Must be a valid DateTime ISO8601 formatted |
| | | 19 | | /// <param name="name">The name of this Migration.</param> |
| | | 20 | | #pragma warning disable CS0618 // Type or member is obsolete |
| | 693 | 21 | | public JellyfinMigrationAttribute(string order, string name) : this(order, name, null) |
| | | 22 | | #pragma warning restore CS0618 // Type or member is obsolete |
| | | 23 | | { |
| | 693 | 24 | | } |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// Initializes a new instance of the <see cref="JellyfinMigrationAttribute"/> class for legacy migrations. |
| | | 28 | | /// </summary> |
| | | 29 | | /// <param name="order">The ordering this migration should be applied to. Must be a valid DateTime ISO8601 formatted |
| | | 30 | | /// <param name="name">The name of this Migration.</param> |
| | | 31 | | /// <param name="key">[ONLY FOR LEGACY MIGRATIONS]The unique key of this migration. Must be a valid Guid formatted s |
| | | 32 | | [Obsolete("This Constructor should only be used for Legacy migrations. Use the (Order,Name) one for all new ones ins |
| | | 33 | | public JellyfinMigrationAttribute(string order, string name, string? key) |
| | | 34 | | { |
| | | 35 | | Order = DateTime.Parse(order, CultureInfo.InvariantCulture); |
| | | 36 | | Name = name; |
| | | 37 | | Stage = JellyfinMigrationStageTypes.AppInitialisation; |
| | | 38 | | if (key is not null) |
| | | 39 | | { |
| | | 40 | | Key = Guid.Parse(key); |
| | | 41 | | } |
| | | 42 | | } |
| | | 43 | | |
| | | 44 | | /// <summary> |
| | | 45 | | /// Gets or Sets a value indicating whether the annoated migration should be executed on a fresh install. |
| | | 46 | | /// </summary> |
| | | 47 | | public bool RunMigrationOnSetup { get; set; } |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// Gets or Sets the stage the annoated migration should be executed at. Defaults to <see cref="JellyfinMigrationSta |
| | | 51 | | /// </summary> |
| | | 52 | | public JellyfinMigrationStageTypes Stage { get; set; } = JellyfinMigrationStageTypes.CoreInitialisation; |
| | | 53 | | |
| | | 54 | | /// <summary> |
| | | 55 | | /// Gets the ordering of the migration. |
| | | 56 | | /// </summary> |
| | | 57 | | public DateTime Order { get; } |
| | | 58 | | |
| | | 59 | | /// <summary> |
| | | 60 | | /// Gets the name of the migration. |
| | | 61 | | /// </summary> |
| | | 62 | | public string Name { get; } |
| | | 63 | | |
| | | 64 | | /// <summary> |
| | | 65 | | /// Gets the Legacy Key of the migration. Not required for new Migrations. |
| | | 66 | | /// </summary> |
| | | 67 | | public Guid? Key { get; } |
| | | 68 | | } |