Fixes migrations and updates the api usages for v8, more manual merging of files
This commit is contained in:
@@ -288,7 +288,8 @@ namespace Umbraco.Core.Migrations.Install
|
||||
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -42, EditorAlias = Constants.PropertyEditors.Aliases.DropDownList, DbType = "Integer" });
|
||||
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -43, EditorAlias = Constants.PropertyEditors.Aliases.CheckBoxList, DbType = "Nvarchar" });
|
||||
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1041, EditorAlias = Constants.PropertyEditors.Aliases.Tags, DbType = "Ntext",
|
||||
Configuration = "{\"group\":\"default\"}" });
|
||||
Configuration = "{\"group\":\"default\", \"storageType\":\"Json\"}"
|
||||
});
|
||||
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1043, EditorAlias = Constants.PropertyEditors.Aliases.ImageCropper, DbType = "Ntext" });
|
||||
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = Constants.DataTypes.DefaultContentListView, EditorAlias = Constants.PropertyEditors.Aliases.ListView, DbType = "Nvarchar",
|
||||
Configuration = "{\"pageSize\":100, \"orderBy\":\"updateDate\", \"orderDirection\":\"desc\", \"layouts\":" + layouts + ", \"includeProperties\":[{\"alias\":\"updateDate\",\"header\":\"Last edited\",\"isSystem\":1},{\"alias\":\"owner\",\"header\":\"Updated by\",\"isSystem\":1}]}" });
|
||||
|
||||
@@ -1,38 +1,30 @@
|
||||
using System;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
using Umbraco.Core.Persistence.DatabaseAnnotations;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenTwelveZero
|
||||
namespace Umbraco.Core.Migrations.Upgrade.V_7_12_0
|
||||
{
|
||||
[Migration("7.12.0", 0, Constants.System.UmbracoMigrationName)]
|
||||
public class AddRelationTypeForMediaFolderOnDelete : MigrationBase
|
||||
{
|
||||
public AddRelationTypeForMediaFolderOnDelete(ISqlSyntaxProvider sqlSyntax, ILogger logger)
|
||||
: base(sqlSyntax, logger)
|
||||
|
||||
public AddRelationTypeForMediaFolderOnDelete(IMigrationContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Up()
|
||||
public override void Migrate()
|
||||
{
|
||||
var exists = Context.Database.FirstOrDefault<RelationTypeDto>("WHERE alias=@alias", new { alias = Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteAlias });
|
||||
if (exists == null)
|
||||
{
|
||||
var relationTypeDto = new RelationTypeDto
|
||||
Insert.IntoTable(Constants.DatabaseSchema.Tables.RelationType).Row(new
|
||||
{
|
||||
Alias = Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteAlias,
|
||||
Name = Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteName,
|
||||
ChildObjectType = Guid.Parse(Constants.ObjectTypes.MediaType),
|
||||
ParentObjectType = Guid.Parse(Constants.ObjectTypes.MediaType),
|
||||
Dual = false
|
||||
};
|
||||
|
||||
Context.Database.Insert(relationTypeDto);
|
||||
alias = Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteAlias,
|
||||
name = Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteName,
|
||||
childObjectType = Constants.ObjectTypes.MediaType,
|
||||
parentObjectType = Constants.ObjectTypes.MediaType,
|
||||
dual = false
|
||||
}).Do();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{ }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +1,32 @@
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Migrations;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenTwelveZero
|
||||
{
|
||||
[Migration("7.12.0", 2, Constants.System.UmbracoMigrationName)]
|
||||
public class IncreaseLanguageIsoCodeColumnLength : MigrationBase
|
||||
{
|
||||
public IncreaseLanguageIsoCodeColumnLength(ISqlSyntaxProvider sqlSyntax, ILogger logger)
|
||||
: base(sqlSyntax, logger)
|
||||
public IncreaseLanguageIsoCodeColumnLength(IMigrationContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Up()
|
||||
public override void Migrate()
|
||||
{
|
||||
Execute.Code(database =>
|
||||
{
|
||||
database.Execute("DROP INDEX [umbracoLanguage].[IX_umbracoLanguage_languageISOCode]");
|
||||
return null;
|
||||
});
|
||||
Delete.Index("IX_umbracoLanguage_languageISOCode").OnTable("umbracoLanguage").Do();
|
||||
|
||||
Alter.Table("umbracoLanguage")
|
||||
.AlterColumn("languageISOCode")
|
||||
.AsString(14)
|
||||
.Nullable();
|
||||
.Nullable()
|
||||
.Do();
|
||||
|
||||
Create.Index("IX_umbracoLanguage_languageISOCode")
|
||||
.OnTable("umbracoLanguage")
|
||||
.OnColumn("languageISOCode")
|
||||
.Unique();
|
||||
.Unique()
|
||||
.Do();
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,19 @@
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenTwelveZero
|
||||
namespace Umbraco.Core.Migrations.Upgrade.V_7_12_0
|
||||
{
|
||||
[Migration("7.12.0", 0, Constants.System.UmbracoMigrationName)]
|
||||
public class RenameTrueFalseField : MigrationBase
|
||||
{
|
||||
public RenameTrueFalseField(ISqlSyntaxProvider sqlSyntax, ILogger logger) : base(sqlSyntax, logger)
|
||||
public RenameTrueFalseField(IMigrationContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Up()
|
||||
public override void Migrate()
|
||||
{
|
||||
//rename the existing true/false field
|
||||
Update.Table("umbracoNode").Set(new { text = "Checkbox" }).Where(new { id = -49 });
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
//set the field back to true/false
|
||||
Update.Table("umbracoNode").Set(new { text = "True/false" }).Where(new { id = -49 });
|
||||
Update.Table(NodeDto.TableName).Set(new { text = "Checkbox" }).Where(new { id = Constants.DataTypes.Boolean }).Do();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,54 +1,47 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenTwelveZero
|
||||
namespace Umbraco.Core.Migrations.Upgrade.V_7_12_0
|
||||
{
|
||||
/// <summary>
|
||||
/// Set the default storageType for the tags datatype to "CSV" to ensure backwards compatibilty since the default is going to be JSON in new versions
|
||||
/// </summary>
|
||||
|
||||
[Migration("7.12.0", 1, Constants.System.UmbracoMigrationName)]
|
||||
public class SetDefaultTagsStorageType: MigrationBase
|
||||
/// </summary>
|
||||
public class SetDefaultTagsStorageType : MigrationBase
|
||||
{
|
||||
public SetDefaultTagsStorageType(ISqlSyntaxProvider sqlSyntax, ILogger logger) : base(sqlSyntax, logger)
|
||||
public SetDefaultTagsStorageType(IMigrationContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Up()
|
||||
public override void Migrate()
|
||||
{
|
||||
if (Context?.Database == null) return;
|
||||
|
||||
|
||||
// We need to get all datatypes with an alias of "umbraco.tags" so we can loop over them and set the missing values if needed
|
||||
var datatypes = Context.Database.Fetch<DataTypeDto>("SELECT * FROM cmsDataType");
|
||||
var tagsDataTypes = datatypes.Where(x => string.Equals(x.PropertyEditorAlias, Constants.PropertyEditors.TagsAlias, StringComparison.InvariantCultureIgnoreCase));
|
||||
var dataTypePreValues = Context.Database.Fetch<DataTypePreValueDto>("SELECT * FROM cmsDataTypePrevalues");
|
||||
var tagsDataTypes = datatypes.Where(x => string.Equals(x.EditorAlias, Constants.PropertyEditors.Aliases.Tags, StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
foreach (var datatype in tagsDataTypes)
|
||||
{
|
||||
// We need to check if the node has a "storageType" set
|
||||
var result = dataTypePreValues.FirstOrDefault(x =>
|
||||
x.DataTypeNodeId == datatype.DataTypeId
|
||||
&& string.Equals(x.Alias, "storageType", StringComparison.InvariantCultureIgnoreCase));
|
||||
var dataTypePreValues = JsonConvert.DeserializeObject<JObject>(datatype.Configuration);
|
||||
|
||||
// if the "storageType" has not been set we do so by adding a new row in the table for the nodid and set it
|
||||
if (result == null)
|
||||
// We need to check if the node has a "storageType" set
|
||||
if (!dataTypePreValues.ContainsKey("storageType"))
|
||||
{
|
||||
Insert.IntoTable("CmsDataTypePrevalues").Row(new
|
||||
{
|
||||
datatypeNodeId = datatype.DataTypeId,
|
||||
value = "Csv",
|
||||
sortOrder = 2,
|
||||
alias = "storageType"
|
||||
});
|
||||
dataTypePreValues["storageType"] = "Csv";
|
||||
}
|
||||
|
||||
Update.Table(Constants.DatabaseSchema.Tables.DataType)
|
||||
.Set(new { config = JsonConvert.SerializeObject(dataTypePreValues) })
|
||||
.Where(new { nodeId = datatype.NodeId })
|
||||
.Do();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,6 @@ namespace Umbraco.Core.Migrations.Upgrade.V_7_12_0
|
||||
: base(context)
|
||||
{ }
|
||||
|
||||
public override void Migrate()
{
Alter.Table("umbracoConsent").AlterColumn("comment").AsString().Nullable();
}
|
||||
public override void Migrate()
{
Alter.Table("umbracoConsent").AlterColumn("comment").AsString().Nullable().Do();
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Umbraco.Core.PropertyEditors
|
||||
/// </summary>
|
||||
public class ValueListConfiguration
|
||||
{
|
||||
[ConfigurationField("items", "Configure", "multivalues", Description = "Add and remove values for the list.")]
|
||||
[ConfigurationField("items", "Configure", "multivalues", Description = "Add, remove or sort values for the list.")]
|
||||
public List<ValueListItem> Items { get; set; } = new List<ValueListItem>();
|
||||
|
||||
public class ValueListItem
|
||||
|
||||
@@ -344,7 +344,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
// check that the template hasn't been created on disk before creating the content type
|
||||
// if it exists, set the new template content to the existing file content
|
||||
string content = GetViewContent(contentTypeAlias);
|
||||
if (content.IsNullOrWhiteSpace() == false)
|
||||
if (content != null)
|
||||
{
|
||||
template.Content = content;
|
||||
}
|
||||
@@ -369,26 +369,29 @@ namespace Umbraco.Core.Services.Implement
|
||||
return OperationResult.Attempt.Succeed<OperationResultType, ITemplate>(OperationResultType.Success, evtMsgs, template);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new template, setting the content if a view exists in the filesystem
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="masterTemplate"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public ITemplate CreateTemplateWithIdentity(string name, string content, ITemplate masterTemplate = null, int userId = 0)
|
||||
{
|
||||
// file might already be on disk, if so grab the content to avoid overwriting
|
||||
var template = new Template(name, name)
|
||||
{
|
||||
Content = content
|
||||
Content = GetViewContent(name) ?? content
|
||||
};
|
||||
|
||||
// check that the template hasn't been created on disk before creating the content type
|
||||
// if it exists, set the new template content to the existing file content
|
||||
string existingContent = GetViewContent(template.Alias);
|
||||
if (existingContent.IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
template.Content = content;
|
||||
}
|
||||
|
||||
|
||||
if (masterTemplate != null)
|
||||
{
|
||||
template.SetMasterTemplate(masterTemplate);
|
||||
}
|
||||
|
||||
SaveTemplate(template, userId);
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
@@ -681,11 +684,11 @@ namespace Umbraco.Core.Services.Implement
|
||||
if (fileName.IsNullOrWhiteSpace())
|
||||
throw new ArgumentNullException(nameof(fileName));
|
||||
|
||||
if (!fileName.EndsWith(".cshtml"))
|
||||
fileName = string.Concat(fileName, ".cshtml");
|
||||
if (!fileName.EndsWith(".cshtml"))
|
||||
fileName = $"{fileName}.cshtml";
|
||||
|
||||
var fs = _templateRepository.GetFileContentStream(fileName);
|
||||
if (fs == null) return string.Empty;
|
||||
if (fs == null) return null;
|
||||
using (var view = new StreamReader(fs))
|
||||
{
|
||||
return view.ReadToEnd().Trim();
|
||||
|
||||
@@ -313,6 +313,10 @@
|
||||
<Compile Include="Logging\RollingFileCleanupAppender.cs" />
|
||||
<Compile Include="Migrations\MigrationBase_Extra.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_7_10_0\RenamePreviewFolder.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_7_12_0\AddRelationTypeForMediaFolderOnDelete.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_7_12_0\IncreaseLanguageIsoCodeColumnLength.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_7_12_0\RenameTrueFalseField.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_7_12_0\SetDefaultTagsStorageType.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_7_12_0\UpdateUmbracoConsent.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_7_8_0\AddIndexToPropertyTypeAliasColumn.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_7_8_0\AddInstructionCountColumn.cs" />
|
||||
|
||||
Reference in New Issue
Block a user