Post review feedback

Less logging @ info level
More re-usable migration
This commit is contained in:
Paul Johnson
2021-10-26 16:30:57 +01:00
parent bba089c24c
commit 86f344c484
2 changed files with 20 additions and 9 deletions

View File

@@ -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
{
@@ -8,12 +7,19 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_18_0
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");
}
}

View File

@@ -65,11 +65,16 @@ namespace Umbraco.Web.Scheduling
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;
}