Webiant Logo Webiant Logo
  1. No results found.

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

AppSettingsMigration.cs

using FluentMigrator;
using Microsoft.AspNetCore.Http.Features;
using Nop.Core.Configuration;
using Nop.Core.Infrastructure;
using Nop.Data;
using Nop.Data.Migrations;
using Nop.Web.Framework.WebOptimizer;

namespace Nop.Web.Framework.Migrations.UpgradeTo470;

[NopMigration("2023-11-17 00:00:00", "Pseudo-migration to update appSettings.json file", MigrationProcessType.Update)]
public class AppSettingsMigration : MigrationBase
{

    public override void Up()
    {
        var fileProvider = EngineContext.Current.Resolve();

        var dataConfig = DataSettingsManager.LoadSettings();
        dataConfig.WithNoLock = false;

        var rootDir = fileProvider.MapPath("~/");
        var woConfig = new WebOptimizerConfig
        {
            CdnUrl = string.Empty,
            HttpsCompression = HttpsCompressionMode.Compress,
            EnableTagHelperBundling = false,
            EnableCaching = true,
            EnableDiskCache = true,
            AllowEmptyBundle = true,
            CacheDirectory = fileProvider.Combine(rootDir, @"wwwroot\bundles")
        };


        AppSettingsHelper.SaveAppSettings(new List { dataConfig, woConfig }, fileProvider);
    }

    public override void Down() { }
}