/// <summary> /// Returns mapped entity descriptor /// </summary> /// <param name="entityType">Type of entity</param> /// <returns>Mapped entity descriptor</returns> public virtual NopEntityDescriptor GetEntityDescriptor(Type entityType) { return(EntityDescriptors.GetOrAdd(entityType, t => { var tableName = NameCompatibilityManager.GetTableName(t); var expression = new CreateTableExpression { TableName = tableName }; var builder = new CreateTableExpressionBuilder(expression, new NullMigrationContext()); builder.RetrieveTableExpressions(t); return new NopEntityDescriptor { EntityName = tableName, Fields = builder.Expression.Columns.Select(column => new NopEntityFieldDescriptor { Name = column.Name, IsPrimaryKey = column.IsPrimaryKey, IsNullable = column.IsNullable, Size = column.Size, Precision = column.Precision, IsIdentity = column.IsIdentity, Type = getPropertyTypeByColumnName(t, column.Name) }).ToList() }; }));
public override void Up() { Create.Index("IX_PCM_Product_and_Category").OnTable(NameCompatibilityManager.GetTableName(typeof(ProductCategory))) .OnColumn(nameof(ProductCategory.CategoryId)).Ascending() .OnColumn(nameof(ProductCategory.ProductId)).Ascending() .WithOptions().NonClustered(); }
public override void Up() { Create.Index("IX_Product_Manufacturer_Mapping_IsFeaturedProduct") .OnTable(NameCompatibilityManager.GetTableName(typeof(ProductManufacturer))) .OnColumn(nameof(ProductManufacturer.IsFeaturedProduct)).Ascending() .WithOptions().NonClustered(); }
/// <summary> /// Retrieves expressions into ICreateExpressionRoot /// </summary> /// <param name="expressionRoot">The root expression for a CREATE operation</param> /// <typeparam name="TEntity">Entity type</typeparam> public static void TableFor <TEntity>(this ICreateExpressionRoot expressionRoot) where TEntity : BaseEntity { var type = typeof(TEntity); var builder = expressionRoot.Table(NameCompatibilityManager.GetTableName(type)) as CreateTableExpressionBuilder; builder.RetrieveTableExpressions(type); }
public override void Up() { Create.Index("IX_PMM_Product_and_Manufacturer").OnTable(NameCompatibilityManager.GetTableName(typeof(ProductManufacturer))) .OnColumn(nameof(ProductManufacturer.ManufacturerId)).Ascending() .OnColumn(nameof(ProductManufacturer.ProductId)).Ascending() .WithOptions().NonClustered(); }
/// <summary> /// Defines the column specifications by default /// </summary> /// <param name="type">Type of entity</param> /// <param name="create">An expression builder for a FluentMigrator.Expressions.CreateTableExpression</param> /// <param name="propertyInfo">Property info</param> /// <param name="canBeNullable">The value indicating whether this column is nullable</param> protected virtual void DefineByOwnType(Type type, CreateTableExpressionBuilder create, PropertyInfo propertyInfo, bool canBeNullable = false) { var propType = propertyInfo.PropertyType; if (Nullable.GetUnderlyingType(propType) is Type uType) { propType = uType; canBeNullable = true; } if (!_typeMapping.ContainsKey(propType)) { return; } if (type == typeof(string) || propType.FindInterfaces((t, o) => t.FullName?.Equals(o.ToString(), StringComparison.InvariantCultureIgnoreCase) ?? false, "System.Collections.IEnumerable").Any()) { canBeNullable = true; } var column = create.WithColumn(NameCompatibilityManager.GetColumnName(type, propertyInfo.Name)); _typeMapping[propType](column); if (canBeNullable) { create.Nullable(); } }
/// <summary> /// Apply entity configuration /// </summary> /// <param name="table">Create table expression builder</param> public override void MapEntity(CreateTableExpressionBuilder table) { table .WithColumn(NameCompatibilityManager.GetColumnName(typeof(ShippingMethodCountryMapping), nameof(ShippingMethodCountryMapping.ShippingMethodId))) .AsInt32().PrimaryKey().ForeignKey <ShippingMethod>() .WithColumn(NameCompatibilityManager.GetColumnName(typeof(ShippingMethodCountryMapping), nameof(ShippingMethodCountryMapping.CountryId))) .AsInt32().PrimaryKey().ForeignKey <Country>(); }
public override void Up() { Create.Index("IX_PSAM_AllowFiltering").OnTable(NameCompatibilityManager.GetTableName(typeof(ProductSpecificationAttribute))) .OnColumn(nameof(ProductSpecificationAttribute.AllowFiltering)).Ascending() .WithOptions().NonClustered() .Include(nameof(ProductSpecificationAttribute.ProductId)) .Include(nameof(ProductSpecificationAttribute.SpecificationAttributeOptionId)); }
/// <summary> /// Apply entity configuration /// </summary> /// <param name="table">Create table expression builder</param> public override void MapEntity(CreateTableExpressionBuilder table) { table .WithColumn(NameCompatibilityManager.GetColumnName(typeof(ProductProductTagMapping), nameof(ProductProductTagMapping.ProductId))) .AsInt32().PrimaryKey().ForeignKey <Product>() .WithColumn(NameCompatibilityManager.GetColumnName(typeof(ProductProductTagMapping), nameof(ProductProductTagMapping.ProductTagId))) .AsInt32().PrimaryKey().ForeignKey <ProductTag>(); }
/// <summary> /// Retrieves expressions into ICreateExpressionRoot /// </summary> /// <param name="expressionRoot">The root expression for a CREATE operation</param> /// <typeparam name="TEntity">Entity type</typeparam> public virtual void BuildTable <TEntity>(ICreateExpressionRoot expressionRoot) { var type = typeof(TEntity); var builder = expressionRoot.Table(NameCompatibilityManager.GetTableName(type)) as CreateTableExpressionBuilder; RetrieveTableExpressions(type, builder); }
/// <summary> /// Apply entity configuration /// </summary> /// <param name="table">Create table expression builder</param> public override void MapEntity(CreateTableExpressionBuilder table) { table .WithColumn(NameCompatibilityManager.GetColumnName(typeof(DiscountManufacturerMapping), nameof(DiscountManufacturerMapping.DiscountId))) .AsInt32().PrimaryKey().ForeignKey <Discount>() .WithColumn(NameCompatibilityManager.GetColumnName(typeof(DiscountManufacturerMapping), nameof(DiscountManufacturerMapping.EntityId))) .AsInt32().PrimaryKey().ForeignKey <Manufacturer>(); }
/// <summary> /// Apply entity configuration /// </summary> /// <param name="table">Create table expression builder</param> public override void MapEntity(CreateTableExpressionBuilder table) { table .WithColumn(NameCompatibilityManager.GetColumnName(typeof(PermissionRecordCustomerRoleMapping), nameof(PermissionRecordCustomerRoleMapping.PermissionRecordId))) .AsInt32().PrimaryKey().ForeignKey <PermissionRecord>() .WithColumn(NameCompatibilityManager.GetColumnName(typeof(PermissionRecordCustomerRoleMapping), nameof(PermissionRecordCustomerRoleMapping.CustomerRoleId))) .AsInt32().PrimaryKey().ForeignKey <CustomerRole>(); }
/// <summary> /// Apply entity configuration /// </summary> /// <param name="table">Create table expression builder</param> public override void MapEntity(CreateTableExpressionBuilder table) { table .WithColumn(NameCompatibilityManager.GetColumnName(typeof(CustomerAddressMapping), nameof(CustomerAddressMapping.AddressId))) .AsInt32().ForeignKey <Address>().PrimaryKey() .WithColumn(NameCompatibilityManager.GetColumnName(typeof(CustomerAddressMapping), nameof(CustomerAddressMapping.CustomerId))) .AsInt32().ForeignKey <Customer>().PrimaryKey(); }
/// <summary> /// Apply entity configuration /// </summary> /// <param name="table">Create table expression builder</param> public override void MapEntity(CreateTableExpressionBuilder table) { table .WithColumn(nameof(Customer.Username)).AsString(1000).Nullable() .WithColumn(nameof(Customer.Email)).AsString(1000).Nullable() .WithColumn(nameof(Customer.EmailToRevalidate)).AsString(1000).Nullable() .WithColumn(nameof(Customer.SystemName)).AsString(400).Nullable() .WithColumn(NameCompatibilityManager.GetColumnName(typeof(Customer), nameof(Customer.BillingAddressId))).AsInt32().ForeignKey <Address>(onDelete: Rule.None).Nullable() .WithColumn(NameCompatibilityManager.GetColumnName(typeof(Customer), nameof(Customer.ShippingAddressId))).AsInt32().ForeignKey <Address>(onDelete: Rule.None).Nullable(); }
/// <summary> /// Gets create table expression for entity type /// </summary> /// <param name="type">Entity type</param> /// <returns>Expression to create a table</returns> public virtual CreateTableExpression GetCreateTableExpression(Type type) { var expression = new CreateTableExpression { TableName = NameCompatibilityManager.GetTableName(type) }; var builder = new CreateTableExpressionBuilder(expression, CreateNullMigrationContext()); RetrieveTableExpressions(type, builder); return(builder.Expression); }
/// <summary> /// Collect the UP migration expressions /// </summary> public override void Up() { if (!Schema.Table(NameCompatibilityManager.GetTableName(typeof(Company))).Exists()) { _migrationManager.BuildTable <Company>(Create); } if (!Schema.Table(NameCompatibilityManager.GetTableName(typeof(CompanyCustomer))).Exists()) { _migrationManager.BuildTable <CompanyCustomer>(Create); } }
/// <summary> /// Specifies a foreign key /// </summary> /// <param name="column">The foreign key column</param> /// <param name="primaryTableName">The primary table name</param> /// <param name="primaryColumnName">The primary tables column name</param> /// <param name="onDelete">Behavior for DELETEs</param> /// <typeparam name="TPrimary"></typeparam> /// <returns>Set column options or create a new column or set a foreign key cascade rule</returns> public static ICreateTableColumnOptionOrForeignKeyCascadeOrWithColumnSyntax ForeignKey <TPrimary>(this ICreateTableColumnOptionOrWithColumnSyntax column, string primaryTableName = null, string primaryColumnName = null, Rule onDelete = Rule.Cascade) where TPrimary : BaseEntity { if (string.IsNullOrEmpty(primaryTableName)) { primaryTableName = NameCompatibilityManager.GetTableName(typeof(TPrimary)); } if (string.IsNullOrEmpty(primaryColumnName)) { primaryColumnName = nameof(BaseEntity.Id); } return(column.Indexed().ForeignKey(primaryTableName, primaryColumnName).OnDelete(onDelete)); }
/// <summary> /// Collect the UP migration expressions /// </summary> public override void Up() { if (!Schema.Table(NameCompatibilityManager.GetTableName(typeof(SpecificationAttributeGroup))).Exists()) { _migrationManager.BuildTable <SpecificationAttributeGroup>(Create); } 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 <SpecificationAttributeGroup>(); } }
/// <summary> /// Collect the UP migration expressions /// </summary> public override void Up() { if (!DataSettingsManager.IsDatabaseInstalled()) { return; } //locales var languages = _languageService.GetAllLanguagesAsync(true).Result; var languageId = languages .FirstOrDefault(lang => lang.UniqueSeoCode == new CultureInfo(NopCommonDefaults.DefaultLanguageCulture).TwoLetterISOLanguageName) ?.Id; _localizationService.AddOrUpdateLocaleResourceAsync(new Dictionary <string, string> { ["Plugins.Tax.Avalara.Fields.UseTaxRateTables"] = "Use tax rate tables to estimate ", ["Plugins.Tax.Avalara.Fields.UseTaxRateTables.Hint"] = "Determine whether to use tax rate tables to estimate. This will be used as a default tax calculation for catalog pages and will be adjusted and reconciled to the final transaction tax during checkout. Tax rates are looked up by zip code (US only) in a file that will be periodically updated from the Avalara (see Schedule tasks).", }, languageId).Wait(); //settings if (!_settingService.SettingExistsAsync(_avalaraTaxSettings, settings => settings.UseTaxRateTables).Result) { _avalaraTaxSettings.UseTaxRateTables = true; } _settingService.SaveSettingAsync(_avalaraTaxSettings).Wait(); //in version 4.50 we added the LastEnabledUtc field to the ScheduleTask entity, //we need to make sure that these changes are applied before inserting new task into the database var scheduleTaskTableName = NameCompatibilityManager.GetTableName(typeof(ScheduleTask)); //add column if not exists if (!Schema.Table(scheduleTaskTableName).Column(nameof(ScheduleTask.LastEnabledUtc)).Exists()) { Alter.Table(scheduleTaskTableName) .AddColumn(nameof(ScheduleTask.LastEnabledUtc)).AsDateTime2().Nullable(); } //schedule task Insert.IntoTable(scheduleTaskTableName).Row(new { Enabled = true, LastEnabledUtc = DateTime.UtcNow, Seconds = AvalaraTaxDefaults.DownloadTaxRatesTask.Days * 24 * 60 * 60, StopOnError = false, Name = AvalaraTaxDefaults.DownloadTaxRatesTask.Name, Type = AvalaraTaxDefaults.DownloadTaxRatesTask.Type }); }
/// <summary> /// Retrieves expressions for building an entity table /// </summary> /// <param name="builder">An expression builder for a FluentMigrator.Expressions.CreateTableExpression</param> /// <param name="type">Type of entity</param> public static void RetrieveTableExpressions(this CreateTableExpressionBuilder builder, Type type) { var typeFinder = Singleton <ITypeFinder> .Instance .FindClassesOfType(typeof(IEntityBuilder)) .FirstOrDefault(t => t.BaseType?.GetGenericArguments().Contains(type) ?? false); if (typeFinder != null) { (EngineContext.Current.ResolveUnregistered(typeFinder) as IEntityBuilder)?.MapEntity(builder); } var expression = builder.Expression; if (!expression.Columns.Any(c => c.IsPrimaryKey)) { var pk = new ColumnDefinition { Name = nameof(BaseEntity.Id), Type = DbType.Int32, IsIdentity = true, TableName = NameCompatibilityManager.GetTableName(type), ModificationType = ColumnModificationType.Create, IsPrimaryKey = true }; expression.Columns.Insert(0, pk); builder.CurrentColumn = pk; } var propertiesToAutoMap = type .GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetProperty) .Where(pi => pi.DeclaringType != typeof(BaseEntity) && !pi.HasAttribute <NotMappedAttribute>() && !pi.HasAttribute <NotColumnAttribute>() && !expression.Columns.Any(x => x.Name.Equals(NameCompatibilityManager.GetColumnName(type, pi.Name), StringComparison.OrdinalIgnoreCase)) && TypeMapping.ContainsKey(GetTypeToMap(pi.PropertyType).propType)); foreach (var prop in propertiesToAutoMap) { var columnName = NameCompatibilityManager.GetColumnName(type, prop.Name); var(propType, canBeNullable) = GetTypeToMap(prop.PropertyType); DefineByOwnType(columnName, propType, builder, canBeNullable); } }
/// <summary> /// Retrieves expressions for building an entity table /// </summary> /// <param name="type">Type of entity</param> /// <param name="builder">An expression builder for a FluentMigrator.Expressions.CreateTableExpression</param> protected void RetrieveTableExpressions(Type type, CreateTableExpressionBuilder builder) { var tp = _typeFinder .FindClassesOfType(typeof(IEntityBuilder)) .FirstOrDefault(t => t.BaseType?.GetGenericArguments().Contains(type) ?? false); if (tp != null) { (EngineContext.Current.ResolveUnregistered(tp) as IEntityBuilder)?.MapEntity(builder); } var expression = builder.Expression; if (!expression.Columns.Any(c => c.IsPrimaryKey)) { var pk = new ColumnDefinition { Name = nameof(BaseEntity.Id), Type = DbType.Int32, IsIdentity = true, TableName = NameCompatibilityManager.GetTableName(type), ModificationType = ColumnModificationType.Create, IsPrimaryKey = true }; expression.Columns.Insert(0, pk); builder.CurrentColumn = pk; } var propertiesToAutoMap = type .GetProperties(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.SetProperty) .Where(p => !expression.Columns.Any(x => x.Name.Equals(NameCompatibilityManager.GetColumnName(type, p.Name), StringComparison.OrdinalIgnoreCase))); foreach (var prop in propertiesToAutoMap) { DefineByOwnType(type, builder, prop); } }
public override void Up() { Create.Index("IX_Forums_Subscription_ForumId").OnTable(NameCompatibilityManager.GetTableName(typeof(ForumSubscription))) .OnColumn(nameof(ForumSubscription.ForumId)).Ascending() .WithOptions().NonClustered(); }
/// <summary> /// Collect the UP migration expressions /// </summary> public override void Up() { // new permission if (!_dataProvider.GetTable <PermissionRecord>().Any(pr => string.Compare(pr.SystemName, "AccessProfiling", true) == 0)) { var profilingPermission = _dataProvider.InsertEntity( new PermissionRecord { Name = "Public store. Access MiniProfiler results", SystemName = "AccessProfiling", Category = "PublicStore" } ); //add it to the Admin role by default var adminRole = _dataProvider .GetTable <CustomerRole>() .FirstOrDefault(x => x.IsSystemRole && x.SystemName == NopCustomerDefaults.AdministratorsRoleName); _dataProvider.InsertEntity( new PermissionRecordCustomerRoleMapping { CustomerRoleId = adminRole.Id, PermissionRecordId = profilingPermission.Id } ); } var activityLogTypeTable = _dataProvider.GetTable <ActivityLogType>(); if (!activityLogTypeTable.Any(alt => string.Compare(alt.SystemKeyword, "AddNewSpecAttributeGroup", true) == 0)) { _dataProvider.InsertEntity( new ActivityLogType { SystemKeyword = "AddNewSpecAttributeGroup", Enabled = true, Name = "Add a new specification attribute group" } ); } if (!activityLogTypeTable.Any(alt => string.Compare(alt.SystemKeyword, "EditSpecAttributeGroup", true) == 0)) { _dataProvider.InsertEntity( new ActivityLogType { SystemKeyword = "EditSpecAttributeGroup", Enabled = true, Name = "Edit a specification attribute group" } ); } if (!activityLogTypeTable.Any(alt => string.Compare(alt.SystemKeyword, "DeleteSpecAttributeGroup", true) == 0)) { _dataProvider.InsertEntity( new ActivityLogType { SystemKeyword = "DeleteSpecAttributeGroup", Enabled = true, Name = "Delete a specification attribute group" } ); } //<MFA #475> if (!_dataProvider.GetTable <PermissionRecord>().Any(pr => string.Compare(pr.SystemName, "ManageMultifactorAuthenticationMethods", true) == 0)) { var multiFactorAuthenticationPermission = _dataProvider.InsertEntity( new PermissionRecord { Name = "Admin area. Manage Multi-factor Authentication Methods", SystemName = "ManageMultifactorAuthenticationMethods", Category = "Configuration" } ); //add it to the Admin role by default var adminRole = _dataProvider .GetTable <CustomerRole>() .FirstOrDefault(x => x.IsSystemRole && x.SystemName == NopCustomerDefaults.AdministratorsRoleName); _dataProvider.InsertEntity( new PermissionRecordCustomerRoleMapping { CustomerRoleId = adminRole.Id, PermissionRecordId = multiFactorAuthenticationPermission.Id } ); } //</MFA #475> //issue-3852 var tableName = nameof(RewardPointsHistory); var rph = Schema.Table(tableName); var columnName = "UsedWithOrder_Id"; if (rph.Column(columnName).Exists()) { var constraintName = "RewardPointsHistory_UsedWithOrder"; if (rph.Constraint(constraintName).Exists()) { Delete.UniqueConstraint(constraintName).FromTable(tableName); } Delete.Column(columnName).FromTable(tableName); } //#3353 var productAttributeCombinationTableName = NameCompatibilityManager.GetTableName(typeof(ProductAttributeCombination)); //add column if (!Schema.Table(productAttributeCombinationTableName).Column(nameof(ProductAttributeCombination.MinStockQuantity)).Exists()) { Alter.Table(productAttributeCombinationTableName) .AddColumn(nameof(ProductAttributeCombination.MinStockQuantity)).AsInt32().NotNullable().SetExistingRowsTo(0); } //#276 AJAX filters var categoryTableName = NameCompatibilityManager.GetTableName(typeof(Category)); var manufacturerTableName = NameCompatibilityManager.GetTableName(typeof(Manufacturer)); var vendorTableName = NameCompatibilityManager.GetTableName(typeof(Vendor)); //remove column var priceRangesColumnName = "PriceRanges"; if (Schema.Table(categoryTableName).Column(priceRangesColumnName).Exists()) { Delete.Column(priceRangesColumnName).FromTable(categoryTableName); } if (Schema.Table(manufacturerTableName).Column(priceRangesColumnName).Exists()) { Delete.Column(priceRangesColumnName).FromTable(manufacturerTableName); } //add column var priceRangeFilteringColumnName = "PriceRangeFiltering"; if (!Schema.Table(categoryTableName).Column(priceRangeFilteringColumnName).Exists()) { Alter.Table(categoryTableName) .AddColumn(priceRangeFilteringColumnName).AsBoolean().NotNullable().SetExistingRowsTo(true); } if (!Schema.Table(manufacturerTableName).Column(priceRangeFilteringColumnName).Exists()) { Alter.Table(manufacturerTableName) .AddColumn(priceRangeFilteringColumnName).AsBoolean().NotNullable().SetExistingRowsTo(true); } if (!Schema.Table(vendorTableName).Column(priceRangeFilteringColumnName).Exists()) { Alter.Table(vendorTableName) .AddColumn(priceRangeFilteringColumnName).AsBoolean().NotNullable().SetExistingRowsTo(true); } //add column var priceFromColumnName = "PriceFrom"; if (!Schema.Table(categoryTableName).Column(priceFromColumnName).Exists()) { Alter.Table(categoryTableName) .AddColumn(priceFromColumnName).AsDecimal().NotNullable().SetExistingRowsTo(0); } if (!Schema.Table(manufacturerTableName).Column(priceFromColumnName).Exists()) { Alter.Table(manufacturerTableName) .AddColumn(priceFromColumnName).AsDecimal().NotNullable().SetExistingRowsTo(0); } if (!Schema.Table(vendorTableName).Column(priceFromColumnName).Exists()) { Alter.Table(vendorTableName) .AddColumn(priceFromColumnName).AsDecimal().NotNullable().SetExistingRowsTo(0); } //add column var priceToColumnName = "PriceTo"; if (!Schema.Table(categoryTableName).Column(priceToColumnName).Exists()) { Alter.Table(categoryTableName) .AddColumn(priceToColumnName).AsDecimal().NotNullable().SetExistingRowsTo(10000); } if (!Schema.Table(manufacturerTableName).Column(priceToColumnName).Exists()) { Alter.Table(manufacturerTableName) .AddColumn(priceToColumnName).AsDecimal().NotNullable().SetExistingRowsTo(10000); } if (!Schema.Table(vendorTableName).Column(priceToColumnName).Exists()) { Alter.Table(vendorTableName) .AddColumn(priceToColumnName).AsDecimal().NotNullable().SetExistingRowsTo(10000); } //add column var manuallyPriceRangeColumnName = "ManuallyPriceRange"; if (!Schema.Table(categoryTableName).Column(manuallyPriceRangeColumnName).Exists()) { Alter.Table(categoryTableName) .AddColumn(manuallyPriceRangeColumnName).AsBoolean().NotNullable().SetExistingRowsTo(false); } if (!Schema.Table(manufacturerTableName).Column(manuallyPriceRangeColumnName).Exists()) { Alter.Table(manufacturerTableName) .AddColumn(manuallyPriceRangeColumnName).AsBoolean().NotNullable().SetExistingRowsTo(false); } if (!Schema.Table(vendorTableName).Column(manuallyPriceRangeColumnName).Exists()) { Alter.Table(vendorTableName) .AddColumn(manuallyPriceRangeColumnName).AsBoolean().NotNullable().SetExistingRowsTo(false); } }
/// <summary> /// Collect the UP migration expressions /// </summary> public override void Up() { var productTableName = NameCompatibilityManager.GetTableName(typeof(Product)); var orderTableName = NameCompatibilityManager.GetTableName(typeof(Order)); var customerTableName = NameCompatibilityManager.GetTableName(typeof(Customer)); var companyTableName = NameCompatibilityManager.GetTableName(typeof(Company)); var scheduleTaskTable = _dataProvider.GetTable <ScheduleTask>(); if (!scheduleTaskTable.Any(alt => string.Compare(alt.Name, "Remind Me Notification Task", true) == 0)) { _dataProvider.InsertEntity( new ScheduleTask { LastEndUtc = null, LastStartUtc = null, LastSuccessUtc = null, StopOnError = true, Type = "Nop.Services.Common.RemindMeNotificationTask, Nop.Services", Enabled = true, Seconds = 2400, Name = "Remind Me Notification Task" } ); } if (!scheduleTaskTable.Any(alt => string.Compare(alt.Name, "Rate Reminder Notification Task", true) == 0)) { _dataProvider.InsertEntity( new ScheduleTask { LastEndUtc = null, LastStartUtc = null, LastSuccessUtc = null, StopOnError = true, Type = "Nop.Services.Common.RateRemainderNotificationTask, Nop.Services", Enabled = true, Seconds = 2400, Name = "Rate Reminder Notification Task" } ); } if (scheduleTaskTable.Any(alt => string.Compare(alt.Name, "Remind Me And Rate Reminder Notification Task", true) == 1)) { var deleteScheduleTask = scheduleTaskTable.Where(x => x.Name == "Remind Me And Rate Reminder Notification Task").Any() ? scheduleTaskTable.Where(x => x.Name == "Remind Me And Rate Reminder Notification Task").FirstOrDefault() : null; if (deleteScheduleTask != null) { _dataProvider.DeleteEntityAsync(deleteScheduleTask); } } var companyEmailColumnName = "Email"; if (!Schema.Table(companyTableName).Column(companyEmailColumnName).Exists()) { Alter.Table(companyTableName) .AddColumn(companyEmailColumnName).AsString().Nullable().SetExistingRowsTo(null); } var ribbonEnableColumnName = "RibbonEnable"; if (!Schema.Table(productTableName).Column(ribbonEnableColumnName).Exists()) { Alter.Table(productTableName) .AddColumn(ribbonEnableColumnName).AsBoolean().NotNullable().SetExistingRowsTo(false); } var ribbonTextColumnName = "RibbonText"; if (!Schema.Table(productTableName).Column(ribbonTextColumnName).Exists()) { Alter.Table(productTableName) .AddColumn(ribbonTextColumnName).AsString().Nullable().SetExistingRowsTo(null); } //order var scheduleDateColumnName = "ScheduleDate"; if (!Schema.Table(orderTableName).Column(scheduleDateColumnName).Exists()) { Alter.Table(orderTableName) .AddColumn(scheduleDateColumnName).AsString().Nullable().SetExistingRowsTo(null); } var ratingColumnName = "Rating"; if (!Schema.Table(orderTableName).Column(ratingColumnName).Exists()) { Alter.Table(orderTableName) .AddColumn(ratingColumnName).AsInt32().NotNullable().SetExistingRowsTo(0); } var ratingTextColumnName = "RatingText"; if (!Schema.Table(orderTableName).Column(ratingTextColumnName).Exists()) { Alter.Table(orderTableName) .AddColumn(ratingTextColumnName).AsString().Nullable().SetExistingRowsTo(null); } var rateNotificationSendColumnName = "RateNotificationSend"; if (!Schema.Table(orderTableName).Column(rateNotificationSendColumnName).Exists()) { Alter.Table(orderTableName) .AddColumn(rateNotificationSendColumnName).AsBoolean().Nullable().SetExistingRowsTo(false); } //customer var pushTokenColumnName = "PushToken"; if (!Schema.Table(customerTableName).Column(pushTokenColumnName).Exists()) { Alter.Table(customerTableName) .AddColumn(pushTokenColumnName).AsString().Nullable().SetExistingRowsTo(null); } var rateReminderNotificationColumnName = "RateReminderNotification"; if (!Schema.Table(customerTableName).Column(rateReminderNotificationColumnName).Exists()) { Alter.Table(customerTableName) .AddColumn(rateReminderNotificationColumnName).AsBoolean().NotNullable().SetExistingRowsTo(true); } var remindMeNotificationColumnName = "RemindMeNotification"; if (!Schema.Table(customerTableName).Column(remindMeNotificationColumnName).Exists()) { Alter.Table(customerTableName) .AddColumn(remindMeNotificationColumnName).AsBoolean().NotNullable().SetExistingRowsTo(true); } var orderStatusNotificationColumnName = "OrderStatusNotification"; if (!Schema.Table(customerTableName).Column(orderStatusNotificationColumnName).Exists()) { Alter.Table(customerTableName) .AddColumn(orderStatusNotificationColumnName).AsBoolean().NotNullable().SetExistingRowsTo(true); } }
static Type getPropertyTypeByColumnName(Type targetType, string name) { var(mappedType, _) = Array.Find(targetType .GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetProperty), pi => name.Equals(NameCompatibilityManager.GetColumnName(targetType, pi.Name))).PropertyType.GetTypeToMap(); return(mappedType); }
public override void Up() { Create.Index("IX_Product_ProductAttribute_Mapping_ProductId_DisplayOrder").OnTable(NameCompatibilityManager.GetTableName(typeof(ProductAttributeMapping))) .OnColumn(nameof(ProductAttributeMapping.ProductId)).Ascending() .OnColumn(nameof(ProductAttributeMapping.DisplayOrder)).Ascending() .WithOptions().NonClustered(); }
public override void Up() { Create.Index("IX_Forums_Group_DisplayOrder").OnTable(NameCompatibilityManager.GetTableName(typeof(ForumGroup))) .OnColumn(nameof(ForumGroup.DisplayOrder)).Ascending() .WithOptions().NonClustered(); }
/// <summary> /// Collect the UP migration expressions /// </summary> public override void Up() { // add column var shipmentTableName = nameof(Shipment); var collectedDateUtcColumnName = "ReadyForPickupDateUtc"; if (!Schema.Table(shipmentTableName).Column(collectedDateUtcColumnName).Exists()) { Alter.Table(shipmentTableName) .AddColumn(collectedDateUtcColumnName).AsDateTime2().Nullable(); } // add message template if (!_dataProvider.GetTable <MessageTemplate>().Any(pr => string.Compare(pr.Name, MessageTemplateSystemNames.ShipmentReadyForPickupCustomerNotification, true) == 0)) { var messageTemplate = _dataProvider.InsertEntity( new MessageTemplate { Name = MessageTemplateSystemNames.ShipmentReadyForPickupCustomerNotification, Subject = "Your order from %Store.Name% has been %if (!%Order.IsCompletelyReadyForPickup%) partially endif%ready for pickup.", Body = $"<p>{Environment.NewLine}<a href=\"%Store.URL%\"> %Store.Name%</a>{Environment.NewLine}<br />{Environment.NewLine}<br />{Environment.NewLine}Hello %Order.CustomerFullName%!,{Environment.NewLine}<br />{Environment.NewLine}Good news! You order has been%if (!%Order.IsCompletelyReadyForPickup%) partially endif%ready for pickup.{Environment.NewLine}<br />{Environment.NewLine}Order Number: %Order.OrderNumber%{Environment.NewLine}<br />{Environment.NewLine}Order Details: <a href=\"%Order.OrderURLForCustomer%\" target=\"_blank\">%Order.OrderURLForCustomer%</a>{Environment.NewLine}<br />{Environment.NewLine}Date Ordered: %Order.CreatedOn%{Environment.NewLine}<br />{Environment.NewLine}<br />{Environment.NewLine}<br />{Environment.NewLine}<br />{Environment.NewLine}Billing Address{Environment.NewLine}<br />{Environment.NewLine}%Order.BillingFirstName% %Order.BillingLastName%{Environment.NewLine}<br />{Environment.NewLine}%Order.BillingAddress1%{Environment.NewLine}<br />{Environment.NewLine}%Order.BillingAddress2%{Environment.NewLine}<br />{Environment.NewLine}%Order.BillingCity% %Order.BillingZipPostalCode%{Environment.NewLine}<br />{Environment.NewLine}%Order.BillingStateProvince% %Order.BillingCountry%{Environment.NewLine}<br />{Environment.NewLine}<br />{Environment.NewLine}<br />{Environment.NewLine}<br />{Environment.NewLine}%if (%Order.Shippable%) Shipping Address{Environment.NewLine}<br />{Environment.NewLine}%Order.ShippingFirstName% %Order.ShippingLastName%{Environment.NewLine}<br />{Environment.NewLine}%Order.ShippingAddress1%{Environment.NewLine}<br />{Environment.NewLine}%Order.ShippingAddress2%{Environment.NewLine}<br />{Environment.NewLine}%Order.ShippingCity% %Order.ShippingZipPostalCode%{Environment.NewLine}<br />{Environment.NewLine}%Order.ShippingStateProvince% %Order.ShippingCountry%{Environment.NewLine}<br />{Environment.NewLine}<br />{Environment.NewLine}Shipping Method: %Order.ShippingMethod%{Environment.NewLine}<br />{Environment.NewLine}<br />{Environment.NewLine} endif% Products ready for pickup:{Environment.NewLine}<br />{Environment.NewLine}<br />{Environment.NewLine}%Shipment.Product(s)%{Environment.NewLine}</p>{Environment.NewLine}", IsActive = true, EmailAccountId = _dataProvider.GetTable <EmailAccount>().FirstOrDefault()?.Id ?? 0 } ); } //#5547 var scheduleTaskTableName = NameCompatibilityManager.GetTableName(typeof(ScheduleTask)); //add column if (!Schema.Table(scheduleTaskTableName).Column(nameof(ScheduleTask.LastEnabledUtc)).Exists()) { Alter.Table(scheduleTaskTableName) .AddColumn(nameof(ScheduleTask.LastEnabledUtc)).AsDateTime2().Nullable(); } else { Alter.Table(scheduleTaskTableName).AlterColumn(nameof(ScheduleTask.LastEnabledUtc)).AsDateTime2().Nullable(); } //#5939 if (!_dataProvider.GetTable <PermissionRecord>().Any(pr => string.Compare(pr.SystemName, "SalesSummaryReport", StringComparison.InvariantCultureIgnoreCase) == 0)) { var salesSummaryReportPermission = _dataProvider.InsertEntity( new PermissionRecord { Name = "Admin area. Access sales summary report", SystemName = "SalesSummaryReport", Category = "Orders" } ); //add it to the Admin role by default var adminRole = _dataProvider .GetTable <CustomerRole>() .FirstOrDefault(x => x.IsSystemRole && x.SystemName == NopCustomerDefaults.AdministratorsRoleName); _dataProvider.InsertEntity( new PermissionRecordCustomerRoleMapping { CustomerRoleId = adminRole.Id, PermissionRecordId = salesSummaryReportPermission.Id } ); } //add column var returnRequestTableName = NameCompatibilityManager.GetTableName(typeof(ReturnRequest)); var returnedQuantityColumnName = "ReturnedQuantity"; if (!Schema.Table(returnRequestTableName).Column(returnedQuantityColumnName).Exists()) { Alter.Table(returnRequestTableName) .AddColumn(returnedQuantityColumnName).AsInt32().NotNullable().SetExistingRowsTo(0); } }
public override void Up() { Create.Index("IX_UrlRecord_Slug") .OnTable(nameof(UrlRecord)) .OnColumn(nameof(UrlRecord.Slug)) .Ascending() .WithOptions() .NonClustered(); Create.Index("IX_UrlRecord_Custom_1").OnTable(nameof(UrlRecord)) .OnColumn(nameof(UrlRecord.EntityId)).Ascending() .OnColumn(nameof(UrlRecord.EntityName)).Ascending() .OnColumn(nameof(UrlRecord.LanguageId)).Ascending() .OnColumn(nameof(UrlRecord.IsActive)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_StoreMapping_EntityId_EntityName").OnTable(nameof(StoreMapping)) .OnColumn(nameof(StoreMapping.EntityId)).Ascending() .OnColumn(nameof(StoreMapping.EntityName)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_ShoppingCartItem_ShoppingCartTypeId_CustomerId").OnTable(nameof(ShoppingCartItem)) .OnColumn(nameof(ShoppingCartItem.ShoppingCartTypeId)).Ascending() .OnColumn(nameof(ShoppingCartItem.CustomerId)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_RelatedProduct_ProductId1").OnTable(nameof(RelatedProduct)) .OnColumn(nameof(RelatedProduct.ProductId1)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_QueuedEmail_SentOnUtc_DontSendBeforeDateUtc_Extended").OnTable(nameof(QueuedEmail)) .OnColumn(nameof(QueuedEmail.SentOnUtc)).Ascending() .OnColumn(nameof(QueuedEmail.DontSendBeforeDateUtc)).Ascending() .WithOptions().NonClustered() .Include(nameof(QueuedEmail.SentTries)); Create.Index("IX_QueuedEmail_CreatedOnUtc").OnTable(nameof(QueuedEmail)) .OnColumn(nameof(QueuedEmail.CreatedOnUtc)).Descending() .WithOptions().NonClustered(); Create.Index("IX_PSAM_SpecificationAttributeOptionId_AllowFiltering").OnTable(NameCompatibilityManager.GetTableName(typeof(ProductSpecificationAttribute))) .OnColumn(nameof(ProductSpecificationAttribute.SpecificationAttributeOptionId)).Ascending() .OnColumn(nameof(ProductSpecificationAttribute.AllowFiltering)).Ascending() .WithOptions().NonClustered() .Include(nameof(ProductSpecificationAttribute.ProductId)); Create.Index("IX_PSAM_AllowFiltering").OnTable(NameCompatibilityManager.GetTableName(typeof(ProductSpecificationAttribute))) .OnColumn(nameof(ProductSpecificationAttribute.AllowFiltering)).Ascending() .WithOptions().NonClustered() .Include(nameof(ProductSpecificationAttribute.ProductId)) .Include(nameof(ProductSpecificationAttribute.SpecificationAttributeOptionId)); Create.Index("IX_Product_VisibleIndividually_Published_Deleted_Extended").OnTable(nameof(Product)) .OnColumn(nameof(Product.VisibleIndividually)).Ascending() .OnColumn(nameof(Product.Published)).Ascending() .OnColumn(nameof(Product.Deleted)).Ascending() .WithOptions().NonClustered() .Include(nameof(Product.Id)) .Include(nameof(Product.AvailableStartDateTimeUtc)) .Include(nameof(Product.AvailableEndDateTimeUtc)); Create.Index("IX_Product_VisibleIndividually").OnTable(nameof(Product)) .OnColumn(nameof(Product.VisibleIndividually)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_ProductTag_Name").OnTable(nameof(ProductTag)) .OnColumn(nameof(ProductTag.Name)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Product_SubjectToAcl").OnTable(nameof(Product)) .OnColumn(nameof(Product.SubjectToAcl)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Product_ShowOnHomepage").OnTable(nameof(Product)) .OnColumn(nameof(Product.ShowOnHomepage)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Product_Published").OnTable(nameof(Product)) .OnColumn(nameof(Product.Published)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Product_ProductAttribute_Mapping_ProductId_DisplayOrder").OnTable(NameCompatibilityManager.GetTableName(typeof(ProductAttributeMapping))) .OnColumn(nameof(ProductAttributeMapping.ProductId)).Ascending() .OnColumn(nameof(ProductAttributeMapping.DisplayOrder)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Product_PriceDatesEtc").OnTable(nameof(Product)) .OnColumn(nameof(Product.Price)).Ascending() .OnColumn(nameof(Product.AvailableStartDateTimeUtc)).Ascending() .OnColumn(nameof(Product.AvailableEndDateTimeUtc)).Ascending() .OnColumn(nameof(Product.Published)).Ascending() .OnColumn(nameof(Product.Deleted)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Product_ParentGroupedProductId").OnTable(nameof(Product)) .OnColumn(nameof(Product.ParentGroupedProductId)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Product_Manufacturer_Mapping_IsFeaturedProduct") .OnTable(NameCompatibilityManager.GetTableName(typeof(ProductManufacturer))) .OnColumn(nameof(ProductManufacturer.IsFeaturedProduct)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Product_LimitedToStores").OnTable(nameof(Product)) .OnColumn(nameof(Product.LimitedToStores)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Product_Delete_Id").OnTable(nameof(Product)) .OnColumn(nameof(Product.Deleted)).Ascending() .OnColumn(nameof(Product.Id)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Product_Deleted_and_Published").OnTable(nameof(Product)) .OnColumn(nameof(Product.Published)).Ascending() .OnColumn(nameof(Product.Deleted)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Product_Category_Mapping_IsFeaturedProduct").OnTable(NameCompatibilityManager.GetTableName(typeof(ProductCategory))) .OnColumn(nameof(ProductCategory.IsFeaturedProduct)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_ProductAttributeValue_ProductAttributeMappingId_DisplayOrder").OnTable(nameof(ProductAttributeValue)) .OnColumn(nameof(ProductAttributeValue.ProductAttributeMappingId)).Ascending() .OnColumn(nameof(ProductAttributeValue.DisplayOrder)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_PMM_Product_and_Manufacturer").OnTable(NameCompatibilityManager.GetTableName(typeof(ProductManufacturer))) .OnColumn(nameof(ProductManufacturer.ManufacturerId)).Ascending() .OnColumn(nameof(ProductManufacturer.ProductId)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_PMM_ProductId_Extended").OnTable(NameCompatibilityManager.GetTableName(typeof(ProductManufacturer))) .OnColumn(nameof(ProductManufacturer.ProductId)).Ascending() .OnColumn(nameof(ProductManufacturer.IsFeaturedProduct)).Ascending() .WithOptions().NonClustered() .Include(nameof(ProductManufacturer.ManufacturerId)); Create.Index("IX_PCM_ProductId_Extended").OnTable(NameCompatibilityManager.GetTableName(typeof(ProductCategory))) .OnColumn(nameof(ProductCategory.ProductId)).Ascending() .OnColumn(nameof(ProductCategory.IsFeaturedProduct)).Ascending() .WithOptions().NonClustered() .Include(nameof(ProductCategory.CategoryId)); Create.Index("IX_PCM_Product_and_Category").OnTable(NameCompatibilityManager.GetTableName(typeof(ProductCategory))) .OnColumn(nameof(ProductCategory.CategoryId)).Ascending() .OnColumn(nameof(ProductCategory.ProductId)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Order_CreatedOnUtc").OnTable(nameof(Order)) .OnColumn(nameof(Order.CreatedOnUtc)).Descending() .WithOptions().NonClustered(); Create.Index("IX_NewsletterSubscription_Email_StoreId").OnTable(nameof(NewsLetterSubscription)) .OnColumn(nameof(NewsLetterSubscription.Email)).Ascending() .OnColumn(nameof(NewsLetterSubscription.StoreId)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Manufacturer_SubjectToAcl").OnTable(nameof(Manufacturer)) .OnColumn(nameof(Manufacturer.SubjectToAcl)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Manufacturer_LimitedToStores").OnTable(nameof(Manufacturer)) .OnColumn(nameof(Manufacturer.LimitedToStores)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Manufacturer_DisplayOrder").OnTable(nameof(Manufacturer)) .OnColumn(nameof(Manufacturer.DisplayOrder)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Log_CreatedOnUtc").OnTable(nameof(Log)) .OnColumn(nameof(Log.CreatedOnUtc)).Descending() .WithOptions().NonClustered(); Create.Index("IX_LocaleStringResource").OnTable(nameof(LocaleStringResource)) .OnColumn(nameof(LocaleStringResource.ResourceName)).Ascending() .OnColumn(nameof(LocaleStringResource.LanguageId)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Language_DisplayOrder").OnTable(nameof(Language)) .OnColumn(nameof(Language.DisplayOrder)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_GetLowStockProducts").OnTable(nameof(Product)) .OnColumn(nameof(Product.Deleted)).Ascending() .OnColumn(nameof(Product.VendorId)).Ascending() .OnColumn(nameof(Product.ProductTypeId)).Ascending() .OnColumn(nameof(Product.ManageInventoryMethodId)).Ascending() .OnColumn(nameof(Product.MinStockQuantity)).Ascending() .OnColumn(nameof(Product.UseMultipleWarehouses)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_GenericAttribute_EntityId_and_KeyGroup").OnTable(nameof(GenericAttribute)) .OnColumn(nameof(GenericAttribute.EntityId)).Ascending() .OnColumn(nameof(GenericAttribute.KeyGroup)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Forums_Subscription_TopicId").OnTable(NameCompatibilityManager.GetTableName(typeof(ForumSubscription))) .OnColumn(nameof(ForumSubscription.TopicId)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Forums_Subscription_ForumId").OnTable(NameCompatibilityManager.GetTableName(typeof(ForumSubscription))) .OnColumn(nameof(ForumSubscription.ForumId)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Forums_Group_DisplayOrder").OnTable(NameCompatibilityManager.GetTableName(typeof(ForumGroup))) .OnColumn(nameof(ForumGroup.DisplayOrder)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Forums_Forum_DisplayOrder").OnTable(NameCompatibilityManager.GetTableName(typeof(Forum))) .OnColumn(nameof(Forum.DisplayOrder)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Customer_Username").OnTable(nameof(Customer)) .OnColumn(nameof(Customer.Username)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Customer_SystemName").OnTable(nameof(Customer)) .OnColumn(nameof(Customer.SystemName)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Customer_Email").OnTable(nameof(Customer)) .OnColumn(nameof(Customer.Email)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Customer_CustomerGuid").OnTable(nameof(Customer)) .OnColumn(nameof(Customer.CustomerGuid)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Customer_CreatedOnUtc").OnTable(nameof(Customer)) .OnColumn(nameof(Customer.CreatedOnUtc)).Descending() .WithOptions().NonClustered(); Create.Index("IX_Currency_DisplayOrder").OnTable(nameof(Currency)) .OnColumn(nameof(Currency.DisplayOrder)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Country_DisplayOrder").OnTable(nameof(Country)) .OnColumn(nameof(Country.DisplayOrder)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Category_ParentCategoryId").OnTable(nameof(Category)) .OnColumn(nameof(Category.ParentCategoryId)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Category_LimitedToStores").OnTable(nameof(Category)) .OnColumn(nameof(Category.LimitedToStores)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Category_DisplayOrder").OnTable(nameof(Category)) .OnColumn(nameof(Category.DisplayOrder)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_Category_Deleted_Extended").OnTable(nameof(Category)) .OnColumn(nameof(Category.Deleted)).Ascending() .WithOptions().NonClustered() .Include(nameof(Category.Id)) .Include(nameof(Category.Name)) .Include(nameof(Category.SubjectToAcl)).Include(nameof(Category.LimitedToStores)) .Include(nameof(Category.Published)); Create.Index("IX_Category_SubjectToAcl").OnTable(nameof(Category)) .OnColumn(nameof(Category.SubjectToAcl)).Ascending() .WithOptions().NonClustered(); Create.Index("IX_ActivityLog_CreatedOnUtc").OnTable(nameof(ActivityLog)) .OnColumn(nameof(ActivityLog.CreatedOnUtc)).Descending() .WithOptions().NonClustered(); Create.Index("IX_AclRecord_EntityId_EntityName").OnTable(nameof(AclRecord)) .OnColumn(nameof(AclRecord.EntityId)).Ascending() .OnColumn(nameof(AclRecord.EntityName)).Ascending() .WithOptions().NonClustered(); }