forked from umbraco/Umbraco-CMS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added database migration to support version cleanup feature
- Loading branch information
Paul Johnson
committed
Oct 26, 2021
1 parent
9773726
commit d865448
Showing
7 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/Umbraco.Core/Migrations/Upgrade/V_8_18_0/AddContentVersionCleanupFeature.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Linq; | ||
using Umbraco.Core.Persistence.Dtos; | ||
|
||
namespace Umbraco.Core.Migrations.Upgrade.V_8_18_0 | ||
{ | ||
class AddContentVersionCleanupFeature : MigrationBase | ||
{ | ||
public AddContentVersionCleanupFeature(IMigrationContext context) | ||
: base(context) { } | ||
|
||
public override void Migrate() | ||
{ | ||
Create.Table<ContentVersionCleanupPolicyDto>().Do(); | ||
|
||
// What's this about, we worry someone else edited table with same change? | ||
var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToList(); | ||
AddColumnIfNotExists<ContentVersionDto>(columns, "preventCleanup"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/Umbraco.Core/Persistence/Dtos/ContentVersionCleanupPolicyDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Data; | ||
using NPoco; | ||
using Umbraco.Core.Persistence.DatabaseAnnotations; | ||
|
||
namespace Umbraco.Core.Persistence.Dtos | ||
{ | ||
[TableName(TableName)] | ||
[PrimaryKey("contentTypeId")] | ||
[ExplicitColumns] | ||
internal class ContentVersionCleanupPolicyDto | ||
{ | ||
public const string TableName = Constants.DatabaseSchema.Tables.ContentVersionCleanupPolicy; | ||
|
||
[Column("contentTypeId")] | ||
[PrimaryKeyColumn(AutoIncrement = false)] | ||
[ForeignKey(typeof(ContentTypeDto), Column = "nodeId", OnDelete = Rule.Cascade)] | ||
public int ContentTypeId { get; set; } | ||
|
||
[Column("keepAllVersionsNewerThanDays")] | ||
[NullSetting(NullSetting = NullSettings.Null)] | ||
public int? KeepAllVersionsNewerThanDays { get; set; } | ||
|
||
[Column("keepLatestVersionPerDayForDays")] | ||
[NullSetting(NullSetting = NullSettings.Null)] | ||
public int? KeepLatestVersionPerDayForDays { get; set; } | ||
|
||
[Column("preventCleanup")] | ||
public bool PreventCleanup { get; set; } | ||
|
||
[Column("updated")] | ||
public DateTime Updated { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters