-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Content step in a migration recipe fails #6356
Comments
/cc @deanmarcussen |
Is there any progress on this issue? Can it be that there are two transactions? One for the recipe migration and one for the migration. Or maybe some content item cache isn't invalidated after the migration recipe. I want to help on this, but I would need some pointers where to look. |
I did some more investigation and I checked the contents of the database table Document. After enabling the feature there are two records for |
I reduced the issue to a bare minimum and it doesn't have anything to do with Taxonomies. I updated the repo: https://github.com/ArieGato/OrchardCore/tree/ariegato/recipe-migration @hishamco can you remove the Taxonomies label? It comes down to this: @sebastienros can this be caused by two transactions in the orm? The reason the problem didn't occur when using TheBlogTheme is that TheBlogTheme is using the feature |
Yes you're right Each recipe step are excuted in a new scope where the session is committed at the end of the scope, so normally it is okay. But migrations are done first when activating the shell, and idem for migration recipes (through the See this line in
|
So, is this a bug? |
No, the migration recipe executed in your |
@jtkech
|
Yes regarding the doc you're right ;) The technical problem is that the first time we create a scope on a shell we activate it by calling activating handlers and this is where migrations are executed, so if in migrations we create a new scope on this shell whose activation is not completed we would call activating handlers again and again. That said, in the same scope it may work because when we do a session save and then a query there is an auto flush so that you get updated data (even if not yet commited) and, since a recent change, without having to redo a session save But migrations create tables / indexes, so if your content step needs them not sure it can work. Anyway, as soon as possible i will try your repo directly and see what happens, i will let you know |
Okay i could repro, there are 2 definition records and the 1rst one doesn't include the If in your migrations i add the That said i found 3 ways to fix it, not so easy to comment, i will do a PR tomorrow with more comments Anyway will be fixed soon ;) |
that's great! Do you want me to create a more complex migration with multiple steps and the original TaxonomyField included in the CustomPart? Also, maybe you can change the title of the issue? It has nothing to do with Taxonomies, but with the Content step in the recipe migration. |
I cherry picked the commit and tested it. It looks like something doesn't work anymore. The newly created content by the recipe migrator is not available to the ContentAliasManager.
// create the categories content item
await _recipeMigrator.ExecuteAsync("addcategory.recipe.json", this);
categoriesContentItemId = await _contentAliasManager.GetContentItemIdAsync("alias:categories"); |
See my comment in the related PR
So in my PR, when you call If you use it in a If you want to use what you did somewhere else (not in a |
I need the Id of the new Taxonomy content item for the Taxonomy field settings. If I understand correctly this is not possible. Then how can I add a Taxonomy field to a ContentPart in a DataMigration when the Taxonomy content item has not yet been created? |
I found a better and simpler way to fix it, see my last comment in #6648, here the main part
And without doing a session detach on this already loaded document, so it fixes the issue and without having to execute a migration recipe in a deferred task, as before. I retried your module in this context and it was working |
Very nice!! I tested a more complex scenario and all works well. I'll try to come up with some more edge cases, but I'm confident it works nice! Thnx. I really appreciate this. |
@ArieGato Cool, thanks for having tried it |
Hi,
A taxonomy field is not added to a custom part when I use a TaxonomyContentItemId that was added by a recipe migration in the same data migration.
I created a repo for this: https://github.com/ArieGato/OrchardCore/tree/ariegato/recipe-migration
To reproduce follow these steps:
The migration checks for the existence of a taxonomy content item by alias. When it's not present it creates it by using a recipe migration.
Now to see how it should work:
When the Taxonomy content item with the alias has already been created, the migration works fine.
Thnx,
Arjan
The text was updated successfully, but these errors were encountered: