diff --git a/Oqtane.Server/Infrastructure/DatabaseManager.cs b/Oqtane.Server/Infrastructure/DatabaseManager.cs index a8164ac1..d058d2fe 100644 --- a/Oqtane.Server/Infrastructure/DatabaseManager.cs +++ b/Oqtane.Server/Infrastructure/DatabaseManager.cs @@ -74,7 +74,6 @@ namespace Oqtane.Infrastructure } } - public bool IsInstalled { get @@ -212,6 +211,8 @@ namespace Oqtane.Infrastructure private static void ModuleMigration(Assembly assembly, string connectionString) { + + Console.WriteLine($"Migrating assembly {assembly.FullName}"); var dbUpgradeConfig = DeployChanges.To.SqlDatabase(connectionString) .WithScriptsEmbeddedInAssembly(assembly); // scripts must be included as Embedded Resources var dbUpgrade = dbUpgradeConfig.Build(); @@ -238,17 +239,19 @@ namespace Oqtane.Infrastructure } } } - + private static void TenantMigration(string connectionString, string dataDirectory) { + Console.WriteLine("Tenant migration"); var assemblies = AppDomain.CurrentDomain.GetAssemblies() - .Where(item => item.FullName != null && item.FullName.Contains(".Module.")).ToArray(); + .Where(item => item.FullName != null && item.FullName.ToLower().Contains(".module.")).ToArray(); // get tenants using (var db = new InstallationContext(connectionString)) { foreach (var tenant in db.Tenant.ToList()) { + Console.WriteLine($"Migrating tenant {tenant.Name}"); connectionString = NormalizeConnectionString(tenant.DBConnectionString, dataDirectory); // upgrade framework var dbUpgradeConfig = DeployChanges.To.SqlDatabase(connectionString) diff --git a/Oqtane.Server/Infrastructure/InstallationManager.cs b/Oqtane.Server/Infrastructure/InstallationManager.cs index 82eab80f..e76016c3 100644 --- a/Oqtane.Server/Infrastructure/InstallationManager.cs +++ b/Oqtane.Server/Infrastructure/InstallationManager.cs @@ -107,7 +107,7 @@ namespace Oqtane.Infrastructure } } - if (install && restart) + if (install) { if (restart) { diff --git a/Oqtane.Server/Program.cs b/Oqtane.Server/Program.cs index e46805e6..d36b9f9b 100644 --- a/Oqtane.Server/Program.cs +++ b/Oqtane.Server/Program.cs @@ -16,8 +16,11 @@ namespace Oqtane.Server var host = BuildWebHost(args); using (var serviceScope = host.Services.GetRequiredService().CreateScope()) { - var manager = serviceScope.ServiceProvider.GetService(); - manager.StartupMigration(); + var installationManager = serviceScope.ServiceProvider.GetService(); + // install any modules or themes stored in nugget, then restart app to ensure all is loaded in order + installationManager.InstallPackages("Modules,Themes", true); + var databaseManager = serviceScope.ServiceProvider.GetService(); + databaseManager.StartupMigration(); } host.Run(); } diff --git a/Oqtane.Server/Startup.cs b/Oqtane.Server/Startup.cs index 714834e1..11ffb877 100644 --- a/Oqtane.Server/Startup.cs +++ b/Oqtane.Server/Startup.cs @@ -201,7 +201,7 @@ namespace Oqtane } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IInstallationManager installationManager) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IInstallationManager installationManager, DatabaseManager databaseManager) { if (env.IsDevelopment()) { @@ -214,9 +214,6 @@ namespace Oqtane app.UseHsts(); } - // install any modules or themes - installationManager.InstallPackages("Modules,Themes", false); - app.UseHttpsRedirection(); app.UseStaticFiles();