Files
Umbraco-CMS/src/Umbraco.Core/Migrations/MigrationContext.cs

49 lines
1.4 KiB
C#
Raw Normal View History

using System;
2019-02-13 09:53:17 +01:00
using System.Collections.Generic;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence;
namespace Umbraco.Core.Migrations
{
2018-11-15 19:34:32 +01:00
/// <summary>
2019-02-13 09:53:17 +01:00
/// Implements <see cref="IMigrationContext"/>.
2018-11-15 19:34:32 +01:00
/// </summary>
internal class MigrationContext : IMigrationContext
{
2018-11-15 19:34:32 +01:00
/// <summary>
/// Initializes a new instance of the <see cref="MigrationContext"/> class.
/// </summary>
public MigrationContext(IUmbracoDatabase database, ILogger logger)
{
Database = database ?? throw new ArgumentNullException(nameof(database));
Logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
2018-11-15 19:34:32 +01:00
/// <inheritdoc />
public ILogger Logger { get; }
2018-11-15 19:34:32 +01:00
/// <inheritdoc />
public IUmbracoDatabase Database { get; }
2018-11-15 19:34:32 +01:00
/// <inheritdoc />
public ISqlContext SqlContext => Database.SqlContext;
2018-11-15 19:34:32 +01:00
/// <inheritdoc />
public int Index { get; set; }
2018-11-15 19:34:32 +01:00
/// <inheritdoc />
public bool BuildingExpression { get; set; }
2019-02-13 09:53:17 +01:00
2019-02-13 10:14:01 +01:00
// this is only internally exposed
2019-02-13 09:53:17 +01:00
public List<Type> PostMigrations { get; } = new List<Type>();
2019-02-13 10:14:01 +01:00
/// <inheritdoc />
public void AddPostMigration<TMigration>()
where TMigration : IMigration
{
2019-05-07 19:28:51 +02:00
// just adding - will be de-duplicated when executing
2019-02-13 10:14:01 +01:00
PostMigrations.Add(typeof(TMigration));
}
}
}