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

Fix Mismatching constraint names in old migration #16891

Merged
merged 3 commits into from
Aug 21, 2024

Conversation

Migaroez
Copy link
Contributor

@Migaroez Migaroez commented Aug 9, 2024

Prerequisites

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

Fixes #16267

Description

Due to older versions of Umbraco not always having had explicit constraint names, some older databases have "system-named constraints" resulting in constraint names not matching up what what we expect in later versions.

This PR takes that behavior into account to change a prior migration that relied on the constraint name being a fixed value. By utilizing the know table name, column name and constraint type (default, which only exists ones per column) we can identify the constraint without relying on it's name.

Testing

Since it is not straight forward to get a DB in a state where it used system-named constraints, I have asked the community to test out this PR on their DB's

I have also tested on the following scenarios to cover as many meaningful permutations as possible.
SQL used to rename the constraint to a bogus one
EXEC sp_rename N'DF_umbracoContentVersion_versionDate', N'DF_umbra#125498', N'OBJECT';

  • test on db mentioned in issue (by the community)
  • test on a v10 db where the constraint in question was manually renamed
  • test on brand new db
  • test on v12.latest db
  • test on v10.tatest db
  • test on v13.0 base db

@Migaroez Migaroez changed the base branch from contrib to v13/dev August 12, 2024 07:55
@Migaroez Migaroez changed the title V13/fix/mismatching constraint name Fix Mismatching constraint names in old migration Aug 20, 2024
@Zeegaan
Copy link
Member

Zeegaan commented Aug 21, 2024

Looks good, tests good 🚀

@Zeegaan Zeegaan merged commit f99f821 into v13/dev Aug 21, 2024
15 checks passed
@Zeegaan Zeegaan deleted the v13/fix/mismatching-constraint-name branch August 21, 2024 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants