Skip to content

Commit

Permalink
Merge pull request #2587 from sbwalker/dev
Browse files Browse the repository at this point in the history
fix #2584 - added IsDeleted columns back to Folder and File tables to preserve compatibility for SQLite
  • Loading branch information
sbwalker authored Feb 8, 2023
2 parents eb87684 + 475894b commit 1663bf8
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Oqtane.Server/Infrastructure/DatabaseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Installation IsInstalled()
}
catch (Exception ex)
{
result.Message = "Master Database Not Installed Correctly. " + ex.Message;
result.Message = "Master Database Not Installed Correctly. " + ex.ToString();
}
}
else // cannot connect
Expand All @@ -74,7 +74,7 @@ public Installation IsInstalled()
}
catch (Exception ex)
{
result.Message = "Cannot Connect To Master Database. " + ex.Message;
result.Message = "Cannot Connect To Master Database. " + ex.ToString();
}
}
}
Expand Down Expand Up @@ -247,7 +247,7 @@ private Installation InstallDatabase(InstallConfig install)
}
catch (Exception ex)
{
result.Message = ex.Message;
result.Message = ex.ToString();
_filelogger.LogError(Utilities.LogMessage(this, result.Message));
}

Expand Down Expand Up @@ -286,7 +286,7 @@ private Installation CreateDatabase(InstallConfig install)
}
catch (Exception ex)
{
result.Message = "An Error Occurred Creating The Database. This Is Usually Related To Your User Not Having Sufficient Rights To Perform This Operation. Please Note That You Can Also Create The Database Manually Prior To Initiating The Install Wizard. " + ex.Message;
result.Message = "An Error Occurred Creating The Database. This Is Usually Related To Your User Not Having Sufficient Rights To Perform This Operation. Please Note That You Can Also Create The Database Manually Prior To Initiating The Install Wizard. " + ex.ToString();
_filelogger.LogError(Utilities.LogMessage(this, result.Message));
}
}
Expand Down Expand Up @@ -327,7 +327,7 @@ private Installation MigrateMaster(InstallConfig install)
}
catch (Exception ex)
{
result.Message = "An Error Occurred Provisioning The Master Database. This Is Usually Related To The Master Database Not Being In A Supported State. " + ex.Message;
result.Message = "An Error Occurred Provisioning The Master Database. This Is Usually Related To The Master Database Not Being In A Supported State. " + ex.ToString();
_filelogger.LogError(Utilities.LogMessage(this, result.Message));
}
}
Expand Down Expand Up @@ -435,7 +435,7 @@ private Installation MigrateTenants(InstallConfig install)
}
catch (Exception ex)
{
result.Message = "An Error Occurred Migrating A Tenant Database. This Is Usually Related To A Tenant Database Not Being In A Supported State. " + ex.Message;
result.Message = "An Error Occurred Migrating A Tenant Database. This Is Usually Related To A Tenant Database Not Being In A Supported State. " + ex.ToString();
_filelogger.LogError(Utilities.LogMessage(this, result.Message));
}

Expand All @@ -456,7 +456,7 @@ private Installation MigrateTenants(InstallConfig install)
}
catch (Exception ex)
{
result.Message = "An Error Occurred Executing Upgrade Logic. " + ex.Message;
result.Message = "An Error Occurred Executing Upgrade Logic. " + ex.ToString();
_filelogger.LogError(Utilities.LogMessage(this, result.Message));
}
}
Expand Down Expand Up @@ -526,7 +526,7 @@ private Installation MigrateModules(InstallConfig install)
}
catch (Exception ex)
{
result.Message = "An Error Occurred Installing " + moduleDefinition.Name + " Version " + versions[i] + " - " + ex.Message;
result.Message = "An Error Occurred Installing " + moduleDefinition.Name + " Version " + versions[i] + " - " + ex.ToString();
}
}
}
Expand Down Expand Up @@ -664,7 +664,7 @@ private Installation CreateSite(InstallConfig install)
}
catch (Exception ex)
{
result.Message = "An Error Occurred Creating Site. " + ex.Message;
result.Message = "An Error Occurred Creating Site. " + ex.ToString();
}
}

Expand Down Expand Up @@ -737,7 +737,7 @@ private Installation MigrateSites()
}
catch (Exception ex)
{
logger.Log(alias.SiteId, Shared.LogLevel.Error, "Site Migration", LogFunction.Other, "An Error Occurred Executing Site Migration {Type} For {Alias} And Version {Version} {Error}", upgrade.Value, alias.Name, version, ex.Message);
logger.Log(alias.SiteId, Shared.LogLevel.Error, "Site Migration", LogFunction.Other, ex, "An Error Occurred Executing Site Migration {Type} For {Alias} And Version {Version}", upgrade.Value, alias.Name, version);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Oqtane.Databases.Interfaces;
using Oqtane.Migrations.EntityBuilders;
using Oqtane.Repository;

namespace Oqtane.Migrations.Tenant
{
[DbContext(typeof(TenantDBContext))]
[Migration("Tenant.03.03.02.01")]
public class AddFolderFileIsDeletedColumns : MultiDatabaseMigration
{
public AddFolderFileIsDeletedColumns(IDatabase database) : base(database)
{
}

protected override void Up(MigrationBuilder migrationBuilder)
{
// IsDeleted columns were removed in 3.2.2 however SQLite does not support column removal so they had to be restored
if (ActiveDatabase.Name != "Sqlite")
{
var folderEntityBuilder = new FolderEntityBuilder(migrationBuilder, ActiveDatabase);
folderEntityBuilder.AddBooleanColumn("IsDeleted");

var fileEntityBuilder = new FileEntityBuilder(migrationBuilder, ActiveDatabase);
fileEntityBuilder.AddBooleanColumn("IsDeleted");
}
}

protected override void Down(MigrationBuilder migrationBuilder)
{
// not implemented
}
}
}
1 change: 1 addition & 0 deletions Oqtane.Server/Repository/FileRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public IEnumerable<File> GetFiles(int folderId)

public File AddFile(File file)
{
file.IsDeleted = false;
_db.File.Add(file);
_db.SaveChanges();
file.Folder = _folderRepository.GetFolder(file.FolderId);
Expand Down
1 change: 1 addition & 0 deletions Oqtane.Server/Repository/FolderRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public IEnumerable<Folder> GetFolders(int siteId)

public Folder AddFolder(Folder folder)
{
folder.IsDeleted = false;
_db.Folder.Add(folder);
_db.SaveChanges();
_permissions.UpdatePermissions(folder.SiteId, EntityNames.Folder, folder.FolderId, folder.Permissions);
Expand Down
5 changes: 5 additions & 0 deletions Oqtane.Shared/Models/File.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public class File : ModelBase
/// </summary>
public string Description { get; set; }

/// <summary>
/// Deprecated - not used
/// </summary>
public bool IsDeleted { get; set; }

/// <summary>
/// Object reference to the <see cref="Folder"/> object.
/// Use this if you need to determine what <see cref="Site"/> the file belongs to.
Expand Down
5 changes: 5 additions & 0 deletions Oqtane.Shared/Models/Folder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public class Folder : ModelBase
/// </summary>
public bool IsSystem { get; set; }

/// <summary>
/// Deprecated - not used
/// </summary>
public bool IsDeleted { get; set; }

/// <summary>
/// TODO: todoc what would this contain?
/// </summary>
Expand Down

0 comments on commit 1663bf8

Please sign in to comment.