deploy-31 Implement DB changes for Umbraco Deploy

This commit is contained in:
Shannon
2015-12-16 14:07:09 +01:00
parent 7cf1491661
commit 8260c12d64
10 changed files with 137 additions and 5 deletions

View File

@@ -24,7 +24,7 @@ namespace Umbraco.Core.Configuration
/// Gets the version comment (like beta or RC).
/// </summary>
/// <value>The version comment.</value>
public static string CurrentComment { get { return ""; } }
public static string CurrentComment { get { return "beta"; } }
// Get the version of the umbraco.dll by looking at a class in that dll
// Had to do it like this due to medium trust issues, see: http://haacked.com/archive/2010/11/04/assembly-location-and-medium-trust.aspx

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.DatabaseAnnotations;
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
namespace Umbraco.Core.Models.Rdbms
{
[TableName("umbracoDeployChecksum")]
[PrimaryKey("id")]
[ExplicitColumns]
internal class UmbracoDeployChecksumDto
{
[Column("id")]
[PrimaryKeyColumn(Name = "PK_umbracoDeployChecksum")]
public int Id { get; set; }
[Column("entityType")]
[Length(32)]
[NullSetting(NullSetting = NullSettings.NotNull)]
[Index(IndexTypes.UniqueNonClustered, Name = "IX_umbracoDeployChecksum", ForColumns = "entityType,entityGuid,entityPath")]
public string EntityType { get; set; }
[Column("entityGuid")]
[NullSetting(NullSetting = NullSettings.Null)]
public Guid EntityGuid { get; set; }
[Column("entityPath")]
[Length(256)]
[NullSetting(NullSetting = NullSettings.Null)]
public string EntityPath { get; set; }
[Column("localChecksum")]
[NullSetting(NullSetting = NullSettings.NotNull)]
[Length(32)]
public string LocalChecksum { get; set; }
[Column("compositeChecksum")]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(32)]
public string CompositeChecksum { get; set; }
}
}

View File

@@ -0,0 +1,30 @@
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.DatabaseAnnotations;
namespace Umbraco.Core.Models.Rdbms
{
[TableName("umbracoDeployDependency")]
[PrimaryKey("id")]
[ExplicitColumns]
internal class UmbracoDeployDependencyDto
{
[Column("id")]
[PrimaryKeyColumn(Name = "PK_umbracoDeployDependency")]
public int Id { get; set; }
[Column("sourceId")]
[ForeignKey(typeof(UmbracoDeployChecksumDto), Name = "FK_umbracoDeployDependency_umbracoDeployChecksum_id1")]
[NullSetting(NullSetting = NullSettings.NotNull)]
public int SourceId { get; set; }
[Column("targetId")]
[ForeignKey(typeof(UmbracoDeployChecksumDto), Name = "FK_umbracoDeployDependency_umbracoDeployChecksum_id2")]
[NullSetting(NullSetting = NullSettings.NotNull)]
public int TargetId { get; set; }
[Column("mode")]
[NullSetting(NullSetting = NullSettings.NotNull)]
public int Mode { get; set; }
}
}

View File

@@ -82,7 +82,9 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
{42, typeof (AccessRuleDto)},
{43, typeof(CacheInstructionDto)},
{44, typeof (ExternalLoginDto)},
{45, typeof (MigrationDto)}
{45, typeof (MigrationDto)},
{46, typeof (UmbracoDeployChecksumDto)},
{47, typeof (UmbracoDeployDependencyDto)}
};
#endregion

View File

@@ -119,6 +119,12 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
return new Version(7, 2, 5);
}
//if the error is for umbracoDeployChecksum it must be the previous version to 7.4 since that is when it is added
if (Errors.Any(x => x.Item1.Equals("Table") && (x.Item2.InvariantEquals("umbracoDeployChecksum"))))
{
return new Version(7, 3, 4);
}
return UmbracoVersion.Current;
}

View File

@@ -0,0 +1,47 @@
using System.Linq;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence.SqlSyntax;
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenFourZero
{
[Migration("7.4.0", 5, GlobalSettings.UmbracoMigrationName)]
public class AddUmbracoDeployTables : MigrationBase
{
public AddUmbracoDeployTables(ISqlSyntaxProvider sqlSyntax, ILogger logger)
: base(sqlSyntax, logger)
{ }
public override void Up()
{
//Don't exeucte if the table is already there
var tables = SqlSyntax.GetTablesInSchema(Context.Database).ToArray();
if (tables.InvariantContains("umbracoDeployChecksum")) return;
Create.Table("umbracoDeployChecksum")
.WithColumn("id").AsInt32().Identity().PrimaryKey("PK_umbracoDeployChecksum")
.WithColumn("entityType").AsString(32).NotNullable()
.WithColumn("entityGuid").AsGuid().Nullable()
.WithColumn("entityPath").AsString(256).Nullable()
.WithColumn("localChecksum").AsString(32).NotNullable()
.WithColumn("compositeChecksum").AsString(32).Nullable();
Create.Table("umbracoDeployDependency")
.WithColumn("id").AsInt32().Identity().PrimaryKey("PK_umbracoDeployDependency")
.WithColumn("sourceId").AsInt32().NotNullable().ForeignKey("FK_umbracoDeployDependency_umbracoDeployChecksum_id1", "umbracoDeployChecksum", "id")
.WithColumn("targetId").AsInt32().NotNullable().ForeignKey("FK_umbracoDeployDependency_umbracoDeployChecksum_id2", "umbracoDeployChecksum", "id")
.WithColumn("mode").AsInt32().NotNullable();
Create.Index("IX_umbracoDeployChecksum").OnTable("umbracoDeployChecksum")
.OnColumn("entityType")
.Ascending()
.OnColumn("entityGuid")
.Ascending()
.OnColumn("entityPath")
.Unique();
}
public override void Down()
{ }
}
}

View File

@@ -12,7 +12,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenFourZer
/// alias, so we need to ensure that these are initially consistent on
/// all environments (based on the alias).
/// </summary>
[Migration("7.4.0", 2, GlobalSettings.UmbracoMigrationName)]
[Migration("7.4.0", 3, GlobalSettings.UmbracoMigrationName)]
public class EnsureContentTypeUniqueIdsAreConsistent : MigrationBase
{
public EnsureContentTypeUniqueIdsAreConsistent(ISqlSyntaxProvider sqlSyntax, ILogger logger)

View File

@@ -5,7 +5,7 @@ using Umbraco.Core.Persistence.SqlSyntax;
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenFourZero
{
[Migration("7.4.0", 3, GlobalSettings.UmbracoMigrationName)]
[Migration("7.4.0", 4, GlobalSettings.UmbracoMigrationName)]
public class RemoveParentIdPropertyTypeGroupColumn : MigrationBase
{
public RemoveParentIdPropertyTypeGroupColumn(ISqlSyntaxProvider sqlSyntax, ILogger logger)

View File

@@ -394,6 +394,8 @@
<Compile Include="Models\Rdbms\DocumentPublishedReadOnlyDto.cs" />
<Compile Include="Models\Rdbms\ExternalLoginDto.cs" />
<Compile Include="Models\Rdbms\MigrationDto.cs" />
<Compile Include="Models\Rdbms\UmbracoDeployChecksumDto.cs" />
<Compile Include="Models\Rdbms\UmbracoDeployDependencyDto.cs" />
<Compile Include="Models\UmbracoDomain.cs" />
<Compile Include="Models\DoNotCloneAttribute.cs" />
<Compile Include="Models\IDomain.cs" />
@@ -409,6 +411,7 @@
<Compile Include="Persistence\Mappers\DomainMapper.cs" />
<Compile Include="Persistence\Mappers\MigrationEntryMapper.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenFourZero\AddDataDecimalColumn.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenFourZero\AddUmbracoDeployTables.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenFourZero\AddUniqueIdPropertyTypeGroupColumn.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenFourZero\RemoveParentIdPropertyTypeGroupColumn.cs" />
<Compile Include="Persistence\Mappers\TaskTypeMapper.cs" />