Skip to content

Conversation

@AndyButland
Copy link
Contributor

Prerequisites

  • I have added steps to test this contribution in the description below

Addresses : #20592

Description

This PR updates the check on whether a data type already exists before creating in a migration to use the GUID rather than the integer ID. In Cloud, with Deploy, there'll be the change of a restored environment creating the data types from the .uda files with a different ID than the one we expect when they are created on new installs or migrations - which then causes a bug as per the linked issue when the migration attempts to create them again.

I've resolved this by using the GUID which will be the same across all environments and installations.

Testing

You can test the migration by rolling back a current database to an earlier state with the following SQL, such that on start up the migration will run again - this will confirm that the creation is skipped still if the data types already exist.

update umbracoKeyValue
set value = '{A917FCBC-C378-4A08-A36C-220C581A6581}'
where [key] = 'Umbraco.Core.Upgrader.State+Umbraco.Core'

Copilot AI review requested due to automatic review settings October 22, 2025 09:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a migration bug where data type existence checks were incorrectly using integer IDs instead of GUIDs. In Cloud environments with Deploy, restored databases can have different integer IDs for the same data types, causing migrations to incorrectly attempt recreation of existing data types.

Key Changes:

  • Replaced Database.Exists<NodeDto> checks with a new GUID-based NodeExists() method
  • Removed unnecessary return value assignments from Database.Insert calls

@lauraneto lauraneto enabled auto-merge (squash) October 22, 2025 10:12
@lauraneto lauraneto merged commit 48759b9 into main Oct 22, 2025
24 of 25 checks passed
@lauraneto lauraneto deleted the v16/bugfix/dont-rely-on-int-ids-in-data-type-creation-migration branch October 22, 2025 10:21
AndyButland added a commit that referenced this pull request Oct 22, 2025
…n creating (#20604)

* Use reliable GUID to check for existence of data type in migration.

* Retrieve just a single field in existence check.
@AndyButland
Copy link
Contributor Author

Cherry-picked for release/17.0.

AndyButland added a commit that referenced this pull request Oct 22, 2025
…n creating (#20604)

* Use reliable GUID to check for existence of data type in migration.

* Retrieve just a single field in existence check.
@AndyButland AndyButland changed the title Migrations: Use reliable GUID to check for existence of data type when creating Migrations: Use reliable GUID to check for existence of data type when creating (closes #20592) Oct 22, 2025
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 this pull request may close these issues.

3 participants