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 · 21 comments · Fixed by #330
Open

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

twozero6 opened this issue Dec 16, 2024 · 21 comments · Fixed by #330
Assignees

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.

@akfakmot akfakmot self-assigned this Jan 6, 2025
@akfakmot
Copy link
Collaborator

akfakmot commented Jan 9, 2025

Hi @twozero6 ,
currently there's a PR with fix. We will let you know once the changes are merged.

The changing content item names are not treated - they shouldn't be an issue for the primary problem and changing it would require deeper cuts into the migration tool. However if you conclude that they are a problem, let us know.

@akfakmot akfakmot linked a pull request Jan 9, 2025 that will close this issue
5 tasks
@akfakmot akfakmot reopened this Jan 9, 2025
@akfakmot
Copy link
Collaborator

akfakmot commented Jan 9, 2025

Hi @twozero6 ,
the fix is merged. Please test your case and let us know if the issue has been resolved. Thank you

@bluemodus-mwills
Copy link

Thank you @akfakmot . We are exited to try this, and are planning to test it on a migration Monday, Jan 13.

@twozero6
Copy link
Author

@akfakmot @bluemodus-mwills this seems to have resolved the issue I was encountering. The pages in the web channel are loading after running the migration two times. The categories are still being duplicated but it doesn't seem to be breaking the page. @akfakmot should I create a separate issue for the categories?

@akfakmot
Copy link
Collaborator

@twozero6 Thanks for testing it. Since categories were also part of the subject of this task, let's solve it within this task before we close. I will try to reproduce once again and get back to you. If it cannot be reproduced on my side, I may need to ask you for further specifics. Let me get back to you.

@bluemodus-mwills
Copy link

Thank you @akfakmot !

@bluemodus-mwills
Copy link

Hiya @akfakmot , is there an ETA for this issue? Thank you!

@akfakmot
Copy link
Collaborator

Hi @bluemodus-mwills, I tested yesterday with negative result. Although I still have a few scenarios to try on my side today, it would speed us up if you could share the migration data and code as offered by @twozero6

Thanks a lot

@twozero6
Copy link
Author

Hi @akfakmot - sorry I didn't follow up here but I mentioned it in these two issues:

#327
#322

I sent the migration code, db, and logs to the email you provided a while back. Please let me know if there is a better way to send it to you. Thank you!

@bluemodus-mwills
Copy link

Thank you, @akfakmot & @twozero6.

@akfakmot -- does that provide what you need? Or, do you need us to resend the code and database another way?

@akfakmot
Copy link
Collaborator

@bluemodus-mwills @twozero6 Thanks. I have the files now. Thanks and I'll be resolving this and the other issues until end of this week.

@akfakmot
Copy link
Collaborator

@twozero6 Unfortunately there's some problem when importing the bacpac. Can I ask you to provide a plain .bak of the xbyk database and include also .bak of the source database? Thank you

@twozero6
Copy link
Author

@akfakmot I uploaded both .bak files to the same location, let me know if you have any trouble with them. Thank you.

@akfakmot
Copy link
Collaborator

@twozero6 Thank you very much. The backup was successfully restored to my server. This is a big help.

@akfakmot
Copy link
Collaborator

Hi @twozero6 , regarding the duplicate categories caused by repeated migration, this should now be fixed in newest Migration Tool release v2.1.0
I tested on the provided database.

@bluemodus-mwills
Copy link

Thank you, @akfakmot !

@twozero6
Copy link
Author

Thank you @akfakmot!

@twozero6
Copy link
Author

twozero6 commented Feb 7, 2025

@twozero6 from what I saw in my testing, this seems to have resolved our issue, but I plan to do more work with this next week and I can confirm then. Thank you!

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

Successfully merging a pull request may close this issue.

4 participants