File tree Expand file tree Collapse file tree 2 files changed +20
-9
lines changed
Umbraco.Core/Migrations/Upgrade/V_8_18_0 Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Original file line number Diff line number Diff line change 1
- using System . Linq ;
2
- using Umbraco . Core . Persistence . Dtos ;
1
+ using Umbraco . Core . Persistence . Dtos ;
3
2
4
3
namespace Umbraco . Core . Migrations . Upgrade . V_8_18_0
5
4
{
@@ -8,12 +7,19 @@ class AddContentVersionCleanupFeature : MigrationBase
8
7
public AddContentVersionCleanupFeature ( IMigrationContext context )
9
8
: base ( context ) { }
10
9
10
+ /// <remarks>
11
+ /// The conditionals are useful to enable the same migration to be used in multiple
12
+ /// migration paths x.x -> 8.18 and x.x -> 9.x
13
+ /// </remarks>
11
14
public override void Migrate ( )
12
15
{
13
- Create . Table < ContentVersionCleanupPolicyDto > ( ) . Do ( ) ;
16
+ var tables = SqlSyntax . GetTablesInSchema ( Context . Database ) ;
17
+ if ( ! tables . InvariantContains ( ContentVersionCleanupPolicyDto . TableName ) )
18
+ {
19
+ Create . Table < ContentVersionCleanupPolicyDto > ( ) . Do ( ) ;
20
+ }
14
21
15
- // What's this about, we worry someone else edited table with same change?
16
- var columns = SqlSyntax . GetColumnsInSchema ( Context . Database ) . ToList ( ) ;
22
+ var columns = SqlSyntax . GetColumnsInSchema ( Context . Database ) ;
17
23
AddColumnIfNotExists < ContentVersionDto > ( columns , "preventCleanup" ) ;
18
24
}
19
25
}
Original file line number Diff line number Diff line change @@ -65,11 +65,16 @@ public override bool PerformRun()
65
65
return false ; // do NOT repeat, going down
66
66
}
67
67
68
- _logger . Info < ContentVersionCleanup > ( "Starting ContentVersionCleanup task." ) ;
68
+ var count = _cleanupService . PerformContentVersionCleanup ( DateTime . Now ) . Count ;
69
69
70
- var report = _cleanupService . PerformContentVersionCleanup ( DateTime . Now ) ;
71
-
72
- _logger . Info < ContentVersionCleanup > ( "Finished ContentVersionCleanup task. Removed {count} item(s)." , report . Count ) ;
70
+ if ( count > 0 )
71
+ {
72
+ _logger . Info < ContentVersionCleanup > ( "Deleted {count} ContentVersion(s)." , count ) ;
73
+ }
74
+ else
75
+ {
76
+ _logger . Debug < ContentVersionCleanup > ( "Task complete, no items were Deleted." ) ;
77
+ }
73
78
74
79
return true ;
75
80
}
You can’t perform that action at this time.
0 commit comments