diff --git a/Oqtane.Server/Infrastructure/DatabaseManager.cs b/Oqtane.Server/Infrastructure/DatabaseManager.cs
index 455fecd6..0729761d 100644
--- a/Oqtane.Server/Infrastructure/DatabaseManager.cs
+++ b/Oqtane.Server/Infrastructure/DatabaseManager.cs
@@ -17,6 +17,7 @@ using Oqtane.Repository;
using Oqtane.Shared;
using Oqtane.Enums;
using Newtonsoft.Json;
+using System.Diagnostics;
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable ConvertToUsingDeclaration
@@ -55,16 +56,25 @@ namespace Oqtane.Infrastructure
{
try
{
+ // verify master database contains a Tenant table ( ie. validate schema is properly provisioned )
var provisioned = db.Tenant.Any();
}
- catch
+ catch (Exception ex)
{
- result.Message = "Master Database Not Installed Correctly";
+ result.Message = "Master Database Not Installed Correctly. " + ex.Message;
}
}
- else
+ else // cannot connect
{
- result.Message = "Cannot Connect To Master Database";
+ try
+ {
+ // get the actual connection error details
+ db.Database.OpenConnection();
+ }
+ catch (Exception ex)
+ {
+ result.Message = "Cannot Connect To Master Database. " + ex.Message;
+ }
}
}
}
@@ -127,6 +137,7 @@ namespace Oqtane.Infrastructure
{
if (!string.IsNullOrEmpty(installation.Message))
{
+ Debug.WriteLine($"Oqtane Error: {installation.Message}");
// problem with prior installation
install.ConnectionString = "";
}
diff --git a/Oqtane.Server/Infrastructure/UpgradeManager.cs b/Oqtane.Server/Infrastructure/UpgradeManager.cs
index 2fec05bb..8ca6533c 100644
--- a/Oqtane.Server/Infrastructure/UpgradeManager.cs
+++ b/Oqtane.Server/Infrastructure/UpgradeManager.cs
@@ -5,7 +5,9 @@ using Newtonsoft.Json;
using Oqtane.Models;
using Oqtane.Repository;
using Oqtane.Shared;
+using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.IO;
using System.Linq;
@@ -48,21 +50,25 @@ namespace Oqtane.Infrastructure
}
}
+ ///
+ /// **Note: this code is commented out on purpose - it provides an example of how to programmatically add a page to all existing sites on upgrade
+ ///
+ ///
+ ///
private void Upgrade_1_0_0(Tenant tenant, IServiceScope scope)
{
- var pageTemplates = new List();
-
- // **Note: this code is commented out on purpose - it provides an example of how to programmatically add a page to all existing sites on upgrade
-
+ //var pageTemplates = new List();
+ //
//pageTemplates.Add(new PageTemplate
//{
// Name = "Test",
// Parent = "",
+ // Order = 1,
// Path = "test",
// Icon = Icons.Badge,
// IsNavigation = true,
// IsPersonalizable = false,
- // EditMode = false,
+ // IsClickable = true,
// PagePermissions = new List
// {
// new Permission(PermissionNames.View, RoleNames.Admin, true),
@@ -84,8 +90,15 @@ namespace Oqtane.Infrastructure
// }
// }
//});
-
- CreateSitePages(scope, pageTemplates);
+ //
+ //if (pageTemplates.Count != 0)
+ //{
+ // var sites = scope.ServiceProvider.GetRequiredService();
+ // foreach (Site site in sites.GetSites().ToList())
+ // {
+ // sites.CreatePages(site, pageTemplates);
+ // }
+ //}
}
private void Upgrade_2_0_2(Tenant tenant, IServiceScope scope)
@@ -100,19 +113,28 @@ namespace Oqtane.Infrastructure
{
Directory.Delete(internalTemplatePath, true);
}
- catch
+ catch (Exception ex)
{
// error deleting directory
+ Debug.WriteLine($"Oqtane Error: Error In 2.0.2 Upgrade Logic - {ex}");
}
}
}
// initialize SiteGuid
- var sites = scope.ServiceProvider.GetRequiredService();
- foreach (Site site in sites.GetSites().ToList())
+ try
{
- site.SiteGuid = System.Guid.NewGuid().ToString();
- sites.UpdateSite(site);
+ var sites = scope.ServiceProvider.GetRequiredService();
+ foreach (Site site in sites.GetSites().ToList())
+ {
+ site.SiteGuid = System.Guid.NewGuid().ToString();
+ sites.UpdateSite(site);
+ }
+ }
+ catch (Exception ex)
+ {
+ // error populating guid
+ Debug.WriteLine($"Oqtane Error: Error In 2.0.2 Upgrade Logic - {ex}");
}
}
@@ -128,16 +150,5 @@ namespace Oqtane.Infrastructure
}
}
- private void CreateSitePages(IServiceScope scope, List pageTemplates)
- {
- if (pageTemplates.Count != 0)
- {
- var sites = scope.ServiceProvider.GetRequiredService();
- foreach (Site site in sites.GetSites().ToList())
- {
- sites.CreatePages(site, pageTemplates);
- }
- }
- }
}
}
diff --git a/Oqtane.Server/Migrations/EntityBuilders/BaseEntityBuilder.cs b/Oqtane.Server/Migrations/EntityBuilders/BaseEntityBuilder.cs
index f7336e6c..f46db6b4 100644
--- a/Oqtane.Server/Migrations/EntityBuilders/BaseEntityBuilder.cs
+++ b/Oqtane.Server/Migrations/EntityBuilders/BaseEntityBuilder.cs
@@ -45,9 +45,9 @@ namespace Oqtane.Migrations.EntityBuilders
return ActiveDatabase.AddAutoIncrementColumn(table, RewriteName(name));
}
- public void AddBooleanColumn(string name)
+ public void AddBooleanColumn(string name, bool nullable = false)
{
- _migrationBuilder.AddColumn(RewriteName(name), RewriteName(EntityTableName));
+ _migrationBuilder.AddColumn(RewriteName(name), RewriteName(EntityTableName), nullable: nullable);
}
protected OperationBuilder AddBooleanColumn(ColumnsBuilder table, string name, bool nullable = false)
@@ -85,7 +85,7 @@ namespace Oqtane.Migrations.EntityBuilders
return table.Column(name: RewriteName(name), nullable: nullable);
}
- public void AddMaxStringColumn(string name, int length, bool nullable = false, bool unicode = true)
+ public void AddMaxStringColumn(string name, bool nullable = false, bool unicode = true)
{
_migrationBuilder.AddColumn(RewriteName(name), RewriteName(EntityTableName), nullable: nullable, unicode: unicode);
}
diff --git a/Oqtane.Server/Migrations/Tenant/02010100_AddPageIsClickable.cs b/Oqtane.Server/Migrations/Tenant/02020001_AddPageIsClickable.cs
similarity index 89%
rename from Oqtane.Server/Migrations/Tenant/02010100_AddPageIsClickable.cs
rename to Oqtane.Server/Migrations/Tenant/02020001_AddPageIsClickable.cs
index c15db40c..89f458c1 100644
--- a/Oqtane.Server/Migrations/Tenant/02010100_AddPageIsClickable.cs
+++ b/Oqtane.Server/Migrations/Tenant/02020001_AddPageIsClickable.cs
@@ -7,7 +7,7 @@ using Oqtane.Repository;
namespace Oqtane.Migrations.Tenant
{
[DbContext(typeof(TenantDBContext))]
- [Migration("Tenant.02.01.01.00")]
+ [Migration("Tenant.02.02.00.01")]
public class AddPageIsClickable : MultiDatabaseMigration
{
public AddPageIsClickable(IDatabase database) : base(database)
@@ -18,7 +18,7 @@ namespace Oqtane.Migrations.Tenant
{
var pageEntityBuilder = new PageEntityBuilder(migrationBuilder, ActiveDatabase);
- pageEntityBuilder.AddBooleanColumn("IsClickable");
+ pageEntityBuilder.AddBooleanColumn("IsClickable", true);
pageEntityBuilder.UpdateColumn("IsClickable", "1");
}
diff --git a/Oqtane.Server/Scripts/MigrateMaster.sql b/Oqtane.Server/Scripts/MigrateMaster.sql
index 197450c7..773d9521 100644
--- a/Oqtane.Server/Scripts/MigrateMaster.sql
+++ b/Oqtane.Server/Scripts/MigrateMaster.sql
@@ -11,7 +11,7 @@ IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'dbo.SchemaVersion
)
END
INSERT INTO __EFMigrationsHistory(MigrationId, ProductVersion, AppliedDate, AppliedVersion)
- VALUES ('Master.01.00.00.00', '5.0.0', SYSDATETIME(), '{{Version}}')
+ VALUES ('Master.01.00.00.00', '5.0.4', SYSDATETIME(), '{{Version}}')
INSERT INTO __EFMigrationsHistory(MigrationId, ProductVersion, AppliedDate, AppliedVersion)
SELECT REPLACE(REPLACE(ScriptName, 'Oqtane.Scripts.', ''), '.sql', '') As MigrationId,
ProductVersion = '5.0.4',
diff --git a/Oqtane.Server/Scripts/MigrateTenant.sql b/Oqtane.Server/Scripts/MigrateTenant.sql
index b80ed4ee..f2e8bb40 100644
--- a/Oqtane.Server/Scripts/MigrateTenant.sql
+++ b/Oqtane.Server/Scripts/MigrateTenant.sql
@@ -11,7 +11,7 @@ IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'dbo.SchemaVersion
)
END
INSERT INTO __EFMigrationsHistory(MigrationId, ProductVersion, AppliedDate, AppliedVersion)
- VALUES ('Tenant.01.00.00.00', '5.0.0', SYSDATETIME(), '{{Version}}')
+ VALUES ('Tenant.01.00.00.00', '5.0.4', SYSDATETIME(), '{{Version}}')
INSERT INTO __EFMigrationsHistory(MigrationId, ProductVersion, AppliedDate, AppliedVersion)
SELECT REPLACE(REPLACE(ScriptName, 'Oqtane.Scripts.', ''), '.sql', '') As MigrationId,
ProductVersion = '5.0.4',