Skip to content

Commit

Permalink
Post review feedback
Browse files Browse the repository at this point in the history
Less logging @ info level
More re-usable migration
  • Loading branch information
Paul Johnson committed Oct 26, 2021
1 parent bba089c commit 86f344c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Linq;
using Umbraco.Core.Persistence.Dtos;
using Umbraco.Core.Persistence.Dtos;

namespace Umbraco.Core.Migrations.Upgrade.V_8_18_0
{
Expand All @@ -8,12 +7,19 @@ class AddContentVersionCleanupFeature : MigrationBase
public AddContentVersionCleanupFeature(IMigrationContext context)
: base(context) { }

/// <remarks>
/// The conditionals are useful to enable the same migration to be used in multiple
/// migration paths x.x -> 8.18 and x.x -> 9.x
/// </remarks>
public override void Migrate()
{
Create.Table<ContentVersionCleanupPolicyDto>().Do();
var tables = SqlSyntax.GetTablesInSchema(Context.Database);
if (!tables.InvariantContains(ContentVersionCleanupPolicyDto.TableName))
{
Create.Table<ContentVersionCleanupPolicyDto>().Do();
}

// What's this about, we worry someone else edited table with same change?
var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToList();
var columns = SqlSyntax.GetColumnsInSchema(Context.Database);
AddColumnIfNotExists<ContentVersionDto>(columns, "preventCleanup");
}
}
Expand Down
13 changes: 9 additions & 4 deletions src/Umbraco.Web/Scheduling/ContentVersionCleanup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,16 @@ public override bool PerformRun()
return false; // do NOT repeat, going down
}

_logger.Info<ContentVersionCleanup>("Starting ContentVersionCleanup task.");
var count = _cleanupService.PerformContentVersionCleanup(DateTime.Now).Count;

var report = _cleanupService.PerformContentVersionCleanup(DateTime.Now);

_logger.Info<ContentVersionCleanup>("Finished ContentVersionCleanup task. Removed {count} item(s).", report.Count);
if (count > 0)
{
_logger.Info<ContentVersionCleanup>("Deleted {count} ContentVersion(s).", count);
}
else
{
_logger.Debug<ContentVersionCleanup>("Task complete, no items were Deleted.");
}

return true;
}
Expand Down

0 comments on commit 86f344c

Please sign in to comment.