-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Migrations: Provide migration for single block property editor #20663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…at requires the old definitions
# Conflicts: # src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impressive work @Migaroez. I've done a test with a single block list in single block mode and a nested one. I see the expect result in the logs after running the migration:
[16:34:01 INF] Found 1 number of blockListConfigurations with UseSingleBlockMode set to true
[16:34:01 INF] Migration starting for all properties of type: Umbraco.BlockList
[16:34:01 INF] Migration starting for all properties of type: Umbraco.RichText
[16:34:01 INF] - 2 properties converted, saving...
[16:34:01 INF] - 2 properties converted, saving...
[16:34:01 INF] Migration succeeded for all properties of type: Umbraco.BlockList
[16:34:01 INF] Migration succeeded for all properties of type: Umbraco.RichText
[16:34:01 INF] At {74332C49-B279-4945-8943-F8F00B1F5949}
[16:34:01 INF] Done
And the expected result on screen:
Here's the migrated data for the former:
{
"layout": {
"Umbraco.SingleBlock": [
{
"$type": "SingleBlockLayoutItem",
"contentUdi": null,
"settingsUdi": null,
"contentKey": "bfad0617-770b-4393-b981-709629eec9b6",
"settingsKey": null
}
]
},
"contentData": [
{
"contentTypeKey": "9d3a2959-4e50-464e-9e84-bf60a8400f80",
"udi": null,
"key": "bfad0617-770b-4393-b981-709629eec9b6",
"values": [
{
"editorAlias": "Umbraco.TextBox",
"culture": null,
"segment": null,
"alias": "text",
"value": "Test 1"
}
]
}
],
"settingsData": [],
"expose": [
{
"contentKey": "bfad0617-770b-4393-b981-709629eec9b6",
"culture": null,
"segment": null
}
]
}
I pushed an update for few minor code warning resolutions but otherwise I think the only thing I'd say in review is that I think I'd benefit from a few more code comments, as there are a few pieces here and it's quite involved.
Please could you look at adding XML header comments on all the interfaces, classes and non-private methods, so it's a bit clearer what everything is for, and perhaps annotate a bit more the main MigrateSingleBlockList file? Especially given we aren't looking active this until Umbraco 18, I think whoever might have a need to debug this - or your future self 😉 - might appreciate it.
AndyButland
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - I think that'll help anyone coming to this in the future and having to make changes or debug issues.
# Conflicts: # src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs
Description
This PR introduces a migration for all BlockLists datatypes and their properties that have correctly been configured with "single mode" to a singleblock equivalent.
The migration has been disabled and will at the earliest be enabled in 18.0 but can be ran by an implementor using their own upgrade plan.
It can also be extended to support other propetyEditors that might encapsulate one of our block based editors.
For more information, consult the documentation_wip.
Testing
A database with one or more blocklists configured with "single mode" will be required. Preferable with that blocklist being nested in other types.
Be warned that the front end part of the single block property editor is not yet ready and you will need to verify the transformation in the db or trough the management api.
In the linked example below, the element doctype has key 'f764977e-72bd-4da4-9b3a-fdcd83592554' and the alias of the single blocklist property is 'single'. (PR lenght doesn't allow including the whole result)
https://gist.github.com/Migaroez/2c025bb1d7c49322431bdc7144bde3c4#file-before-migration-json
https://gist.github.com/Migaroez/2c025bb1d7c49322431bdc7144bde3c4#file-after-migration-json