Webiant Logo Webiant Logo
  1. No results found.

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

SpecificationAttributeGroupingMigration.cs

using FluentMigrator;
using Nop.Core.Domain.Catalog;
using Nop.Data.Extensions;
using Nop.Data.Mapping;

namespace Nop.Data.Migrations.UpgradeTo440;

[NopSchemaMigration("2020/03/08 11:26:08:9037680", "Specification attribute grouping")]
public class SpecificationAttributeGroupingMigration : ForwardOnlyMigration
{
    #region Methods

    /// 
    /// Collect the UP migration expressions
    /// 
    public override void Up()
    {
        if (!Schema.Table(NameCompatibilityManager.GetTableName(typeof(SpecificationAttributeGroup))).Exists())
            Create.TableFor();

        if (!Schema.Table(NameCompatibilityManager.GetTableName(typeof(SpecificationAttribute))).Column(nameof(SpecificationAttribute.SpecificationAttributeGroupId)).Exists())
        {
            //add new column
            Alter.Table(NameCompatibilityManager.GetTableName(typeof(SpecificationAttribute)))
                .AddColumn(nameof(SpecificationAttribute.SpecificationAttributeGroupId)).AsInt32().Nullable().ForeignKey();
        }
    }

    #endregion
}