We have moved to GitHub Issues
Created by Mikkel Holck Madsen 03 Aug 2017, 07:42:26 Updated by Mikkel Holck Madsen 10 Aug 2017, 08:43:49
Subtask of: U4-8632
When upgrading an existing site, that contains a number of users, the migration will fail, if two users has the same username. The userName isnt unique, its the userLogin that is. This means that it will try to insert dublicates into the new umbracoUserGroup table.
i.e. we have two users called Peter Nielsen(userName), who is created with two different emails(userLogin).
This is the exception shown in the log(sorry for the danish exceptions):
2017-08-03 08:50:29,131 [P79936/D4/T40] ERROR Umbraco.Web.Install.Controllers.InstallApiController - Installation step DatabaseUpgrade failed. System.Reflection.TargetInvocationException: Destinationen for en aktivering udlÃ¸ste en undtagelse. ---> Umbraco.Web.Install.InstallException: The database failed to upgrade. ERROR: The database configuration failed with the following message: A duplicate value cannot be inserted into a unique index. [ Table name = umbracoUserGroup,Constraint name = IX_umbracoUserGroup_userGroupAlias ] Please check log file for additional information (can be found in '/App_Data/Logs/UmbracoTraceLog.txt') ved Umbraco.Web.Install.InstallSteps.DatabaseUpgradeStep.Execute(Object model)
And it seems to come from the SQL in Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenSevenZero.AddUserGroupTables.MigrateUserPermissions
// Create user group records for all non-admin users that have specific permissions set Execute.Sql(@"INSERT INTO umbracoUserGroup(userGroupAlias, userGroupName) SELECT userName + 'Group', 'Group for ' + userName FROM umbracoUser WHERE (id IN ( SELECT " + SqlSyntax.GetQuotedColumnName("user") + @" FROM umbracoUser2app ) OR id IN ( SELECT userid FROM umbracoUser2NodePermission )) AND id > 0");
Where the Select will return dublicates if there are two of the same usernames
Yeah exactly, it was the umbraco.com site i did it on. but really any site could do, if you can create two users with the same name, and different emails
This also fixes the requirement to create a custom user group for ever user. Now a custom user group will only be created per-user if the user has granular content permissions assigned. For section access, we will now create "Migrated Section Access Group"s for each unique section access combination and assign users appropriately. For example, see screenshot - these 2 groups are created for the .com upgrade instead of a group per user.
Much better, this is awesome.
Took the umbraco website through the upgrader and it worked like a charm, only two groups were added, and the ones with the same names were migrated just fine!
Backwards Compatible: True
Affected versions: 7.7.0
Due in version: 7.7.0
Sprint: Sprint 65
Story Points: 1