< Summary - Jellyfin

Information
Class: Jellyfin.Server.Migrations.JellyfinMigrationAttribute
Assembly: jellyfin
File(s): /srv/git/jellyfin/Jellyfin.Server/Migrations/JellyfinMigrationAttribute.cs
Line coverage
100%
Covered lines: 2
Uncovered lines: 0
Coverable lines: 2
Total lines: 68
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%

File(s)

/srv/git/jellyfin/Jellyfin.Server/Migrations/JellyfinMigrationAttribute.cs

#LineLine coverage
 1#pragma warning disable CA1019 // Define accessors for attribute arguments
 2
 3using System;
 4using System.Globalization;
 5using Jellyfin.Server.Migrations.Stages;
 6
 7namespace 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)]
 13public 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
 37821    public JellyfinMigrationAttribute(string order, string name) : this(order, name, null)
 22#pragma warning restore CS0618 // Type or member is obsolete
 23    {
 37824    }
 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.CoreInitialisaition;
 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}