Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

NopColumnsConvention.cs

using FluentMigrator.Expressions;
using FluentMigrator.Runner.Conventions;

namespace Nop.Data.Migrations;

/// 
/// Column type convention
/// 
public class NopColumnsConvention : IColumnsConvention
{
    #region Methods

    /// 
    /// Applies a convention to a FluentMigrator.Expressions.IColumnsExpression
    /// 
    /// The expression this convention should be applied to
    /// The same or a new expression. The underlying type must stay the same
    public IColumnsExpression Apply(IColumnsExpression expression)
    {
        var dataSettings = DataSettingsManager.LoadSettings();

        if (dataSettings.DataProvider != DataProviderType.PostgreSQL)
            return expression;

        foreach (var columnDefinition in expression.Columns)
        {
            if (columnDefinition.Type != System.Data.DbType.String)
                continue;

            columnDefinition.Type = null;
            columnDefinition.CustomType = "citext";
        }

        return expression;
    }

    #endregion
}