Try your search with a different keyword or use * as a wildcard.
using FluentMigrator.Expressions;
using FluentMigrator.Model;
using FluentMigrator.Runner.Conventions;
namespace Nop.Data.Migrations;
///
/// Convention for the default naming of an index
///
public class NopIndexConvention : IIndexConvention
{
#region Fields
protected readonly INopDataProvider _dataProvider;
#endregion
#region Ctor
public NopIndexConvention(INopDataProvider dataProvider)
{
_dataProvider = dataProvider;
}
#endregion
#region Utilities
///
/// Gets the default name of an index
///
/// The index definition
/// Name of an index
protected virtual string GetIndexName(IndexDefinition index)
{
return _dataProvider.GetIndexName(index.TableName, string.Join('_', index.Columns.Select(c => c.Name)));
}
#endregion
#region Methods
///
/// Applies a convention to a FluentMigrator.Expressions.IIndexExpression
///
/// The expression this convention should be applied to
/// The same or a new expression. The underlying type must stay the same.
public IIndexExpression Apply(IIndexExpression expression)
{
if (string.IsNullOrEmpty(expression.Index.Name))
expression.Index.Name = GetIndexName(expression.Index);
return expression;
}
#endregion
}