Skip to content
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

Error when rerunning a migration for a type that uses a reusable schema #320

Open
twozero6 opened this issue Dec 16, 2024 · 3 comments
Open

Comments

@twozero6
Copy link

When working with any significant migration we need the ability to rerun the migration, just like we can without using custom class mappings, or when using UMT. It enables fixing issues and rerunning it without having to start over.
Furthermore, without this, there's no chance we could migrate delta content changes, even if we used the approach of rerunning in an empty database, serialize to CI, and merging CI changes.

It gives us the impression that there's a case where Guid.NewGuid() is being used when migrating content like maybe here. But, it would be better to require us to provide a static Guid -- one that would be the same with every migration runs.

This issue is a significant hinderance to using one of the most powerful features -- custom class mapping.

I have a custom ClassMapping class for several page\content types. Those types have multiple reusable schemas as well as standalone fields.

After I run the migration for the first time, the pages of those types work fine in the content tree.
After I run the migration for the second time, the pages show "Something went wrong!" with this error in the Event Log:

An unhandled exception has occurred while executing the request.
Message: An item with the same key has already been added. Key: ReusablePageTitle

Every field in the mapping class for the Reusable Schemas and every field in the Types using those schemas have a unique but static GUID assigned to them. The types themselves also have a unique but static GUID.

@twozero6
Copy link
Author

Just to add, the names of content items seem to be changing for each migration. I believe it's due to the "GetSafeCodename" method that generates random characters. Changing the method to return a calculated \ consistent value would allow us to get the same results on multiple runs.

@DavidSlavik
Copy link
Contributor

Hello Sandro,

Thanks for letting us know. Our team will investigate this, and we will fix it if it is a bug.

The estimated time for delivery is the 2nd or 3rd week in January 2025.

@twozero6
Copy link
Author

Thank you, @DavidSlavik! Just in case it helps, I wanted show you a couple more things I noticed as I was working on a migration project.

When running a migration for the second time and then generating CI files, content types that have a custom mapping class seem to get a second copy of their reusable schemas:

image

For types that do not have a custom mapping class, these ID and GUID values change:

image

For both mapped and non-mapped types, the "Category_Legacy" values get duplicated:

image

Please let me know if I can help with the investigation in any other way. I'd be happy to provide a copy of the code and database if it would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants