This might be related to the changes made back in January (https://github.com/aspnetzero/aspnet-zero-core/issues/2892) or with the DB migration 20200305082815_Upgraded_To_Abp_5_3 but not sure. If I change the index specified in the error to not be unique I can then create an OU again but I am not sure what impact that might have on the system.
If I add an OU at the root level and then delete it and try to add another OU at the root level I get the following error in my logs. I also get this error if I add, delete and then try to add a child OU. Also, when I look at my DB I do have a row for Tenant 2 and Code 00002 but it is flagged as IsDeleted.
Cannot insert duplicate key row in object 'dbo.AbpOrganizationUnits' with unique index 'IX_AbpOrganizationUnits_TenantId_Code'. The duplicate key value is (2, 00002)
I have found another post related to this and it looks like some code changes were made back in January to fix this (https://github.com/aspnetzero/aspnet-zero-core/issues/2892). Those changes are in my source and the objects seem to be getting soft deleted when I look at the DB. They still show up in the UI though. I am using the ASP.NET Core + Angular solution.
I had an Organization Unit with a Role and a User associated with it. I deleted the OU and now when I edit the User it shows that it still has the Role and that it is from an OU, but it does not show any OU anywhere. The problem is there is no way to remove this Role from the user now so it will be there forever. I have not tested if the User still gets the permission for that Role, but my guess is it will.
Is this expected behavior? Seems strange to me if it is since OU's and Roles are built in feature and not something I should have to mess with unless I want to enhance it somehow. I would expect that if I delete an OU then the Roles and Permissions that it was granting are no longer granted and do not show up in the UI.