2021-10-29 15:00:27 +02:00
|
|
|
using Umbraco.Cms.Infrastructure.Migrations;
|
|
|
|
|
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
|
|
|
|
|
using Umbraco.Extensions;
|
2021-10-15 15:45:21 +01:00
|
|
|
|
2021-11-02 09:18:15 +01:00
|
|
|
namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_9_1_0
|
2021-10-15 15:45:21 +01:00
|
|
|
{
|
|
|
|
|
class AddContentVersionCleanupFeature : MigrationBase
|
|
|
|
|
{
|
|
|
|
|
public AddContentVersionCleanupFeature(IMigrationContext context)
|
|
|
|
|
: base(context) { }
|
|
|
|
|
|
2021-10-26 16:30:57 +01:00
|
|
|
/// <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>
|
2021-10-29 15:00:27 +02:00
|
|
|
protected override void Migrate()
|
2021-10-15 15:45:21 +01:00
|
|
|
{
|
2021-10-26 16:30:57 +01:00
|
|
|
var tables = SqlSyntax.GetTablesInSchema(Context.Database);
|
|
|
|
|
if (!tables.InvariantContains(ContentVersionCleanupPolicyDto.TableName))
|
|
|
|
|
{
|
|
|
|
|
Create.Table<ContentVersionCleanupPolicyDto>().Do();
|
|
|
|
|
}
|
2021-10-15 15:45:21 +01:00
|
|
|
|
2021-10-26 16:30:57 +01:00
|
|
|
var columns = SqlSyntax.GetColumnsInSchema(Context.Database);
|
2021-10-15 15:45:21 +01:00
|
|
|
AddColumnIfNotExists<ContentVersionDto>(columns, "preventCleanup");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|