Files
pgsql-jellyfin/Jellyfin.Server/Migrations/JellyfinMigrationAttribute.cs
T
wjones ede6904433 Add Jellyfin.CodeAnalysis and analyzers to all projects
Integrated Jellyfin.CodeAnalysis as a project reference across core and test projects. Added centrally managed code analysis and style enforcement packages (IDisposableAnalyzers, Microsoft.CodeAnalysis.BannedApiAnalyzers, SerilogAnalyzer, SmartAnalyzers.MultithreadingAnalyzer, StyleCop.Analyzers) to all affected projects. Updated dependency graphs, asset files, and build scripts to ensure analyzers run during builds, enforcing consistent code quality and style rules throughout the codebase. Removed custom warning properties to rely on analyzer enforcement.
2026-02-23 07:03:54 -05:00

79 lines
3.1 KiB
C#

// <copyright file="JellyfinMigrationAttribute.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable CA1019 // Define accessors for attribute arguments
using System;
using System.Globalization;
using Jellyfin.Server.Migrations.Stages;
namespace Jellyfin.Server.Migrations;
/// <summary>
/// Declares an class as an migration with its set metadata.
/// </summary>
[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
public sealed class JellyfinMigrationAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="JellyfinMigrationAttribute"/> class.
/// </summary>
/// <param name="order">The ordering this migration should be applied to. Must be a valid DateTime ISO8601 formatted string.</param>
/// <param name="name">The name of this Migration.</param>
#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
{
}
/// <summary>
/// Initializes a new instance of the <see cref="JellyfinMigrationAttribute"/> class for legacy migrations.
/// </summary>
/// <param name="order">The ordering this migration should be applied to. Must be a valid DateTime ISO8601 formatted string.</param>
/// <param name="name">The name of this Migration.</param>
/// <param name="key">[ONLY FOR LEGACY MIGRATIONS]The unique key of this migration. Must be a valid Guid formatted string.</param>
[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);
}
}
/// <summary>
/// Gets or Sets a value indicating whether the annoated migration should be executed on a fresh install.
/// </summary>
public bool RunMigrationOnSetup { get; set; }
/// <summary>
/// Gets or Sets a value indicating whether the migration requires SQLite (legacy library.db).
/// If true, the migration will be skipped when using non-SQLite database providers.
/// </summary>
public bool RequiresSqlite { get; set; }
/// <summary>
/// Gets or Sets the stage the annoated migration should be executed at. Defaults to <see cref="JellyfinMigrationStageTypes.CoreInitialisation"/>.
/// </summary>
public JellyfinMigrationStageTypes Stage { get; set; } = JellyfinMigrationStageTypes.CoreInitialisation;
/// <summary>
/// Gets the ordering of the migration.
/// </summary>
public DateTime Order { get; }
/// <summary>
/// Gets the name of the migration.
/// </summary>
public string Name { get; }
/// <summary>
/// Gets the Legacy Key of the migration. Not required for new Migrations.
/// </summary>
public Guid? Key { get; }
}