Adds migration for binary column on cmsContentNu
This commit is contained in:
@@ -191,8 +191,9 @@ namespace Umbraco.Core.Migrations.Upgrade
|
||||
To<MissingContentVersionsIndexes>("{EE288A91-531B-4995-8179-1D62D9AA3E2E}");
|
||||
To<AddMainDomLock>("{2AB29964-02A1-474D-BD6B-72148D2A53A2}");
|
||||
|
||||
|
||||
// to 8.7.0...
|
||||
To<MissingDictionaryIndex>("{a78e3369-8ea3-40ec-ad3f-5f76929d2b20}");
|
||||
To<AddCmsContentNuByteColumn>("{8DDDCD0B-D7D5-4C97-BD6A-6B38CA65752F}");
|
||||
|
||||
//FINAL
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Migrations.Upgrade.V_8_6_0
|
||||
{
|
||||
public class AddCmsContentNuByteColumn : MigrationBase
|
||||
{
|
||||
public AddCmsContentNuByteColumn(IMigrationContext context)
|
||||
: base(context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
{
|
||||
var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToList();
|
||||
|
||||
AddColumnIfNotExists<ContentNuDto>(columns, "dataRaw");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,13 @@ namespace Umbraco.Core.Persistence.Dtos
|
||||
/// </remarks>
|
||||
[Column("data")]
|
||||
[SpecialDbType(SpecialDbTypes.NTEXT)]
|
||||
[NullSetting(NullSetting = NullSettings.Null)]
|
||||
public string Data { get; set; }
|
||||
|
||||
[Column("dataRaw")]
|
||||
[NullSetting(NullSetting = NullSettings.Null)]
|
||||
public byte[] RawData { get; set; }
|
||||
|
||||
[Column("rv")]
|
||||
public long Rv { get; set; }
|
||||
}
|
||||
|
||||
@@ -132,6 +132,7 @@
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_0\Models\ContentTypeDto80.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_0\Models\PropertyDataDto80.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_0\Models\PropertyTypeDto80.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_8_7_0\AddCmsContentNuByteColumn.cs" />
|
||||
<Compile Include="Models\ContentDataIntegrityReport.cs" />
|
||||
<Compile Include="Models\ContentDataIntegrityReportEntry.cs" />
|
||||
<Compile Include="Models\ContentDataIntegrityReportOptions.cs" />
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
public int EditWriterId { get; set; }
|
||||
public int EditTemplateId { get; set; }
|
||||
public string EditData { get; set; }
|
||||
public byte[] EditDataRaw { get; set; }
|
||||
|
||||
// published data
|
||||
public int PublishedVersionId { get; set; }
|
||||
@@ -35,5 +36,6 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
public int PubWriterId { get; set; }
|
||||
public int PubTemplateId { get; set; }
|
||||
public string PubData { get; set; }
|
||||
public byte[] PubDataRaw { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,9 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
.AndSelect<ContentNuDto>("nuEdit", x => Alias(x.Data, "EditData"))
|
||||
.AndSelect<ContentNuDto>("nuPub", x => Alias(x.Data, "PubData"))
|
||||
|
||||
.AndSelect<ContentNuDto>("nuEdit", x => Alias(x.RawData, "EditDataRaw"))
|
||||
.AndSelect<ContentNuDto>("nuPub", x => Alias(x.RawData, "PubDataRaw"))
|
||||
|
||||
.From<NodeDto>();
|
||||
|
||||
if (joins != null)
|
||||
@@ -136,6 +139,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
.AndSelect<ContentDto>(x => Alias(x.ContentTypeId, "ContentTypeId"))
|
||||
.AndSelect<ContentVersionDto>(x => Alias(x.Id, "VersionId"), x => Alias(x.Text, "EditName"), x => Alias(x.VersionDate, "EditVersionDate"), x => Alias(x.UserId, "EditWriterId"))
|
||||
.AndSelect<ContentNuDto>("nuEdit", x => Alias(x.Data, "EditData"))
|
||||
.AndSelect<ContentNuDto>("nuEdit", x => Alias(x.RawData, "EditDataRaw"))
|
||||
.From<NodeDto>();
|
||||
|
||||
if (joins != null)
|
||||
@@ -211,7 +215,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
|
||||
if (dto.Edited)
|
||||
{
|
||||
if (dto.EditData == null)
|
||||
if (dto.EditData == null && dto.EditDataRaw == null)
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
throw new Exception("Missing cmsContentNu edited content for node " + dto.Id + ", consider rebuilding.");
|
||||
@@ -219,7 +223,9 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
}
|
||||
else
|
||||
{
|
||||
var nested = _contentNestedDataSerializer.Deserialize(dto.EditData);
|
||||
var nested = _contentNestedDataSerializer is IContentNestedDataByteSerializer byteSerializer
|
||||
? byteSerializer.DeserializeBytes(dto.EditDataRaw)
|
||||
: _contentNestedDataSerializer.Deserialize(dto.EditData);
|
||||
|
||||
d = new ContentData
|
||||
{
|
||||
@@ -238,7 +244,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
|
||||
if (dto.Published)
|
||||
{
|
||||
if (dto.PubData == null)
|
||||
if (dto.PubData == null && dto.PubDataRaw == null)
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
throw new Exception("Missing cmsContentNu published content for node " + dto.Id + ", consider rebuilding.");
|
||||
@@ -246,7 +252,9 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
}
|
||||
else
|
||||
{
|
||||
var nested = _contentNestedDataSerializer.Deserialize(dto.PubData);
|
||||
var nested = _contentNestedDataSerializer is IContentNestedDataByteSerializer byteSerializer
|
||||
? byteSerializer.DeserializeBytes(dto.PubDataRaw)
|
||||
: _contentNestedDataSerializer.Deserialize(dto.PubData);
|
||||
|
||||
p = new ContentData
|
||||
{
|
||||
@@ -279,10 +287,12 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
|
||||
private ContentNodeKit CreateMediaNodeKit(ContentSourceDto dto)
|
||||
{
|
||||
if (dto.EditData == null)
|
||||
if (dto.EditData == null && dto.EditDataRaw == null)
|
||||
throw new Exception("No data for media " + dto.Id);
|
||||
|
||||
var nested = _contentNestedDataSerializer.Deserialize(dto.EditData);
|
||||
var nested = _contentNestedDataSerializer is IContentNestedDataByteSerializer byteSerializer
|
||||
? byteSerializer.DeserializeBytes(dto.EditDataRaw)
|
||||
: _contentNestedDataSerializer.Deserialize(dto.EditData);
|
||||
|
||||
var p = new ContentData
|
||||
{
|
||||
|
||||
@@ -6,9 +6,17 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
{
|
||||
// TODO: We need a better name, not sure why the class is called ContentNested in the first place
|
||||
public interface IContentNestedDataByteSerializer : IContentNestedDataSerializer
|
||||
{
|
||||
ContentNestedData DeserializeBytes(byte[] data);
|
||||
byte[] SerializeBytes(ContentNestedData nestedData);
|
||||
}
|
||||
|
||||
// TODO: We need a better name, not sure why the class is called ContentNested in the first place
|
||||
public interface IContentNestedDataSerializer
|
||||
{
|
||||
ContentNestedData Deserialize(string data);
|
||||
string Serialize(ContentNestedData nestedData);
|
||||
ContentNestedData Deserialize(string data);
|
||||
string Serialize(ContentNestedData nestedData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
{
|
||||
internal class MsgPackContentNestedDataSerializer : IContentNestedDataSerializer
|
||||
internal class MsgPackContentNestedDataSerializer : IContentNestedDataByteSerializer
|
||||
{
|
||||
private MessagePackSerializerOptions _options;
|
||||
|
||||
@@ -39,8 +39,6 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
return json;
|
||||
}
|
||||
|
||||
// TODO: Instead of returning base64 it would be more ideal to avoid that translation entirely and just store/retrieve raw bytes
|
||||
|
||||
public ContentNestedData Deserialize(string data)
|
||||
{
|
||||
var bin = Convert.FromBase64String(data);
|
||||
@@ -54,6 +52,10 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
return Convert.ToBase64String(bin);
|
||||
}
|
||||
|
||||
public ContentNestedData DeserializeBytes(byte[] data) => MessagePackSerializer.Deserialize<ContentNestedData>(data, _options);
|
||||
|
||||
public byte[] SerializeBytes(ContentNestedData nestedData) => MessagePackSerializer.Serialize(nestedData, _options);
|
||||
|
||||
//private class ContentNestedDataResolver : IFormatterResolver
|
||||
//{
|
||||
// // GetFormatter<T>'s get cost should be minimized so use type cache.
|
||||
|
||||
@@ -1322,9 +1322,10 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
var dto = GetDto(content, published);
|
||||
db.InsertOrUpdate(dto,
|
||||
"SET data=@data, rv=rv+1 WHERE nodeId=@id AND published=@published",
|
||||
"SET data=@data, dataRaw=@dataRaw, rv=rv+1 WHERE nodeId=@id AND published=@published",
|
||||
new
|
||||
{
|
||||
dataRaw = dto.RawData,
|
||||
data = dto.Data,
|
||||
id = dto.NodeId,
|
||||
published = dto.Published
|
||||
@@ -1456,7 +1457,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
NodeId = content.Id,
|
||||
Published = published,
|
||||
Data = _contentNestedDataSerializer.Serialize(nestedData)
|
||||
Data = !(_contentNestedDataSerializer is IContentNestedDataByteSerializer) ? _contentNestedDataSerializer.Serialize(nestedData) : null,
|
||||
RawData = (_contentNestedDataSerializer is IContentNestedDataByteSerializer byteSerializer) ? byteSerializer.SerializeBytes(nestedData) : null
|
||||
};
|
||||
|
||||
//Core.Composing.Current.Logger.Debug<PublishedSnapshotService>(dto.Data);
|
||||
|
||||
Reference in New Issue
Block a user