using Microsoft.Extensions.Logging; using Umbraco.Cms.Infrastructure.Persistence; namespace Umbraco.Cms.Infrastructure.Migrations; /// /// Implements . /// internal class MigrationContext : IMigrationContext { private readonly List _postMigrations = new(); /// /// Initializes a new instance of the class. /// public MigrationContext(MigrationPlan plan, IUmbracoDatabase? database, ILogger logger) { Plan = plan; Database = database ?? throw new ArgumentNullException(nameof(database)); Logger = logger ?? throw new ArgumentNullException(nameof(logger)); } // this is only internally exposed [Obsolete("This will be removed in the V13, and replaced with a RebuildCache flag on the MigrationBase")] internal IReadOnlyList PostMigrations => _postMigrations; /// public ILogger Logger { get; } public MigrationPlan Plan { get; } /// public IUmbracoDatabase Database { get; internal set; } /// public ISqlContext SqlContext => Database.SqlContext; /// public int Index { get; set; } /// public bool BuildingExpression { get; set; } /// [Obsolete("This will be removed in the V13, and replaced with a RebuildCache flag on the MigrationBase, and a UmbracoPlanExecutedNotification.")] public void AddPostMigration() where TMigration : MigrationBase => // just adding - will be de-duplicated when executing _postMigrations.Add(typeof(TMigration)); }