updates migration and base data creation to create the 3 default list views
This commit is contained in:
@@ -22,6 +22,10 @@
|
||||
/// </summary>
|
||||
public const int RecycleBinMedia = -21;
|
||||
|
||||
public const int DefaultContentListViewDataTypeId = 1037;
|
||||
public const int DefaultMediaListViewDataTypeId = 1038;
|
||||
public const int DefaultMembersListViewDataTypeId = 1039;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,9 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1034, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1034", SortOrder = 2, UniqueId = new Guid("a6857c73-d6e9-480c-b6e6-f15f6ad11125"), Text = "Content Picker", NodeObjectType = new Guid(Constants.ObjectTypes.DataType), CreateDate = DateTime.Now });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1035, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1035", SortOrder = 2, UniqueId = new Guid("93929b9a-93a2-4e2a-b239-d99334440a59"), Text = "Media Picker", NodeObjectType = new Guid(Constants.ObjectTypes.DataType), CreateDate = DateTime.Now });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1036, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1036", SortOrder = 2, UniqueId = new Guid("2b24165f-9782-4aa3-b459-1de4a4d21f60"), Text = "Member Picker", NodeObjectType = new Guid(Constants.ObjectTypes.DataType), CreateDate = DateTime.Now });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1037, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1037", SortOrder = 2, UniqueId = new Guid("C0808DD3-8133-4E4B-8CE8-E2BEA84A96A4"), Text = "List View", NodeObjectType = new Guid(Constants.ObjectTypes.DataType), CreateDate = DateTime.Now });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = Constants.System.DefaultContentListViewDataTypeId, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1037", SortOrder = 2, UniqueId = new Guid("C0808DD3-8133-4E4B-8CE8-E2BEA84A96A4"), Text = "List View - Content", NodeObjectType = new Guid(Constants.ObjectTypes.DataType), CreateDate = DateTime.Now });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = Constants.System.DefaultMediaListViewDataTypeId, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1038", SortOrder = 2, UniqueId = new Guid("3A0156C4-3B8C-4803-BDC1-6871FAA83FFF"), Text = "List View - Media", NodeObjectType = new Guid(Constants.ObjectTypes.DataType), CreateDate = DateTime.Now });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = Constants.System.DefaultMembersListViewDataTypeId, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1039", SortOrder = 2, UniqueId = new Guid("AA2C52A0-CE87-4E65-A47C-7DF09358585D"), Text = "List View - Members", NodeObjectType = new Guid(Constants.ObjectTypes.DataType), CreateDate = DateTime.Now });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1040, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1040", SortOrder = 2, UniqueId = new Guid("21e798da-e06e-4eda-a511-ed257f78d4fa"), Text = "Related Links", NodeObjectType = new Guid(Constants.ObjectTypes.DataType), CreateDate = DateTime.Now });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1041, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1041", SortOrder = 2, UniqueId = new Guid("b6b73142-b9c1-4bf8-a16d-e1c23320b549"), Text = "Tags", NodeObjectType = new Guid(Constants.ObjectTypes.DataType), CreateDate = DateTime.Now });
|
||||
_database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1043, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1043", SortOrder = 2, UniqueId = new Guid("1df9f033-e6d4-451f-b8d2-e0cbc50a836f"), Text = "Image Cropper", NodeObjectType = new Guid(Constants.ObjectTypes.DataType), CreateDate = DateTime.Now });
|
||||
@@ -232,8 +234,10 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 15, DataTypeId = -43, PropertyEditorAlias = Constants.PropertyEditors.CheckBoxListAlias, DbType = "Nvarchar" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 16, DataTypeId = 1034, PropertyEditorAlias = Constants.PropertyEditors.ContentPickerAlias, DbType = "Integer" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 17, DataTypeId = 1035, PropertyEditorAlias = Constants.PropertyEditors.MediaPickerAlias, DbType = "Integer" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 18, DataTypeId = 1036, PropertyEditorAlias = Constants.PropertyEditors.MemberPickerAlias, DbType = "Integer" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 19, DataTypeId = 1037, PropertyEditorAlias = Constants.PropertyEditors.ListViewAlias, DbType = "Nvarchar" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 18, DataTypeId = 1036, PropertyEditorAlias = Constants.PropertyEditors.MemberPickerAlias, DbType = "Integer" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 19, DataTypeId = Constants.System.DefaultContentListViewDataTypeId, PropertyEditorAlias = Constants.PropertyEditors.ListViewAlias, DbType = "Nvarchar" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 20, DataTypeId = Constants.System.DefaultMediaListViewDataTypeId, PropertyEditorAlias = Constants.PropertyEditors.ListViewAlias, DbType = "Nvarchar" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 23, DataTypeId = Constants.System.DefaultMembersListViewDataTypeId, PropertyEditorAlias = Constants.PropertyEditors.ListViewAlias, DbType = "Nvarchar" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 21, DataTypeId = 1040, PropertyEditorAlias = Constants.PropertyEditors.RelatedLinksAlias, DbType = "Ntext" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 22, DataTypeId = 1041, PropertyEditorAlias = Constants.PropertyEditors.TagsAlias, DbType = "Ntext" });
|
||||
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 24, DataTypeId = 1043, PropertyEditorAlias = Constants.PropertyEditors.ImageCropperAlias, DbType = "Ntext" });
|
||||
|
||||
@@ -13,11 +13,9 @@ using umbraco.interfaces;
|
||||
namespace Umbraco.Web.Strategies.Migrations
|
||||
{
|
||||
/// <summary>
|
||||
/// Once the migration runner is run, this will ensure that the content types that are flagged as list views,
|
||||
/// have the special readonly list view property type on the readonly tab. This will ensure that the built in system list view data type exists if the
|
||||
/// current version is less than 7.2 (because previous to 7.2 we didn't ship with the system created list view data type)
|
||||
/// Creates the built in list view data types
|
||||
/// </summary>
|
||||
public class EnsureAllListViewContentTypesHaveListViewPropertyType : ApplicationEventHandler
|
||||
public class EnsureDefaultListViewDataTypesCreated : ApplicationEventHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Ensure this is run when not configured
|
||||
@@ -52,17 +50,7 @@ namespace Umbraco.Web.Strategies.Migrations
|
||||
if (e.ConfiguredVersion <= target720)
|
||||
{
|
||||
EnsureListViewDataTypeCreated(e);
|
||||
|
||||
var services = ApplicationContext.Current.Services;
|
||||
|
||||
var contentTypes = services.ContentTypeService.GetAllContentTypes().Where(x => x.IsContainer);
|
||||
services.ContentTypeService.Save(AddListView(contentTypes));
|
||||
|
||||
var mediaTypes = services.ContentTypeService.GetAllMediaTypes().Where(x => x.IsContainer);
|
||||
services.ContentTypeService.Save(AddListView(mediaTypes));
|
||||
|
||||
var memberTypes = services.MemberTypeService.GetAll().Where(x => x.IsContainer);
|
||||
services.MemberTypeService.Save(AddListView(memberTypes));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,21 +65,9 @@ namespace Umbraco.Web.Strategies.Migrations
|
||||
if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert())
|
||||
e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName("umbracoNode"))));
|
||||
|
||||
e.MigrationContext.Database
|
||||
.Insert("umbracoNode", "id", false, new NodeDto
|
||||
{
|
||||
NodeId = 1037,
|
||||
Trashed = false,
|
||||
ParentId = -1,
|
||||
UserId = 0,
|
||||
Level = 1,
|
||||
Path = "-1,1037",
|
||||
SortOrder = 2,
|
||||
UniqueId = new Guid("C0808DD3-8133-4E4B-8CE8-E2BEA84A96A4"),
|
||||
Text = "List View",
|
||||
NodeObjectType = new Guid(Constants.ObjectTypes.DataType),
|
||||
CreateDate = DateTime.Now
|
||||
});
|
||||
e.MigrationContext.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = Constants.System.DefaultContentListViewDataTypeId, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1037", SortOrder = 2, UniqueId = new Guid("C0808DD3-8133-4E4B-8CE8-E2BEA84A96A4"), Text = "List View - Content", NodeObjectType = new Guid(Constants.ObjectTypes.DataType), CreateDate = DateTime.Now });
|
||||
e.MigrationContext.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = Constants.System.DefaultMediaListViewDataTypeId, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1038", SortOrder = 2, UniqueId = new Guid("3A0156C4-3B8C-4803-BDC1-6871FAA83FFF"), Text = "List View - Media", NodeObjectType = new Guid(Constants.ObjectTypes.DataType), CreateDate = DateTime.Now });
|
||||
e.MigrationContext.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = Constants.System.DefaultMembersListViewDataTypeId, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1039", SortOrder = 2, UniqueId = new Guid("AA2C52A0-CE87-4E65-A47C-7DF09358585D"), Text = "List View - Members", NodeObjectType = new Guid(Constants.ObjectTypes.DataType), CreateDate = DateTime.Now });
|
||||
|
||||
//Turn off identity insert if db provider is not mysql
|
||||
if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert())
|
||||
@@ -101,14 +77,9 @@ namespace Umbraco.Web.Strategies.Migrations
|
||||
if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert())
|
||||
e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName("cmsDataType"))));
|
||||
|
||||
e.MigrationContext.Database
|
||||
.Insert("cmsDataType", "pk", false, new DataTypeDto
|
||||
{
|
||||
PrimaryKey = 19,
|
||||
DataTypeId = 1037,
|
||||
PropertyEditorAlias = Constants.PropertyEditors.ListViewAlias,
|
||||
DbType = "Nvarchar"
|
||||
});
|
||||
e.MigrationContext.Database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 19, DataTypeId = Constants.System.DefaultContentListViewDataTypeId, PropertyEditorAlias = Constants.PropertyEditors.ListViewAlias, DbType = "Nvarchar" });
|
||||
e.MigrationContext.Database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 20, DataTypeId = Constants.System.DefaultMediaListViewDataTypeId, PropertyEditorAlias = Constants.PropertyEditors.ListViewAlias, DbType = "Nvarchar" });
|
||||
e.MigrationContext.Database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 23, DataTypeId = Constants.System.DefaultMembersListViewDataTypeId, PropertyEditorAlias = Constants.PropertyEditors.ListViewAlias, DbType = "Nvarchar" });
|
||||
|
||||
//Turn off identity insert if db provider is not mysql
|
||||
if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert())
|
||||
@@ -118,33 +89,6 @@ namespace Umbraco.Web.Strategies.Migrations
|
||||
}
|
||||
}
|
||||
|
||||
private static List<T> AddListView<T>(IEnumerable<T> contentTypes)
|
||||
where T: IContentTypeBase
|
||||
{
|
||||
var toSave = new List<T>();
|
||||
foreach (var contentType in contentTypes)
|
||||
{
|
||||
if (contentType.PropertyGroups.Contains(Constants.Conventions.PropertyGroups.ListViewGroupName) == false)
|
||||
{
|
||||
contentType.PropertyGroups.Add(new PropertyGroup
|
||||
{
|
||||
Name = Constants.Conventions.PropertyGroups.ListViewGroupName,
|
||||
SortOrder = contentType.PropertyGroups.Any() ? contentType.PropertyGroups.Max(x => x.SortOrder) + 1 : 1,
|
||||
PropertyTypes = new PropertyTypeCollection(new[]
|
||||
{
|
||||
new PropertyType(Constants.PropertyEditors.ListViewAlias, DataTypeDatabaseType.Nvarchar)
|
||||
{
|
||||
Alias = Constants.Conventions.PropertyTypes.ListViewPropertyAlias,
|
||||
Name = Constants.Conventions.PropertyTypes.ListViewPropertyAlias,
|
||||
DataTypeDefinitionId = 1037
|
||||
}
|
||||
})
|
||||
});
|
||||
toSave.Add(contentType);
|
||||
}
|
||||
}
|
||||
return toSave;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user