From a430518cdb76b2f9690378f9608c116ac696d7f2 Mon Sep 17 00:00:00 2001 From: SmithThe4th Date: Wed, 22 Feb 2023 19:11:16 -0500 Subject: [PATCH] [PM-1128] Add Migration to Sync OrganizationUserUserDetailsView (#2732) * Updated OrganizationUserUserDetailsView to include AccessSecretsManager which was missing in the migration hence making the view script out of sync with the migrations * Formatted file * Formatted file --- ...ganizationUserUserDetailsViewOutOfSync.sql | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 util/Migrator/DbScripts/2023-02-22_FixOrganizationUserUserDetailsViewOutOfSync.sql diff --git a/util/Migrator/DbScripts/2023-02-22_FixOrganizationUserUserDetailsViewOutOfSync.sql b/util/Migrator/DbScripts/2023-02-22_FixOrganizationUserUserDetailsViewOutOfSync.sql new file mode 100644 index 000000000..6e0ed991c --- /dev/null +++ b/util/Migrator/DbScripts/2023-02-22_FixOrganizationUserUserDetailsViewOutOfSync.sql @@ -0,0 +1,45 @@ +CREATE OR ALTER VIEW [dbo].[OrganizationUserUserDetailsView] +AS +SELECT + OU.[Id], + OU.[UserId], + OU.[OrganizationId], + U.[Name], + ISNULL(U.[Email], OU.[Email]) Email, + U.[AvatarColor], + U.[TwoFactorProviders], + U.[Premium], + OU.[Status], + OU.[Type], + OU.[AccessAll], + OU.[AccessSecretsManager], + OU.[ExternalId], + SU.[ExternalId] SsoExternalId, + OU.[Permissions], + OU.[ResetPasswordKey], + U.[UsesKeyConnector] +FROM + [dbo].[OrganizationUser] OU +LEFT JOIN + [dbo].[User] U ON U.[Id] = OU.[UserId] +LEFT JOIN + [dbo].[SsoUser] SU ON SU.[UserId] = OU.[UserId] AND SU.[OrganizationId] = OU.[OrganizationId] +GO + +IF OBJECT_ID('[dbo].[OrganizationUserUserDetails_ReadById]') IS NOT NULL +BEGIN + EXECUTE sp_refreshsqlmodule N'[dbo].[OrganizationUserUserDetails_ReadById]'; +END +GO + +IF OBJECT_ID('[dbo].[OrganizationUserUserDetails_ReadByOrganizationId]') IS NOT NULL +BEGIN + EXECUTE sp_refreshsqlmodule N'[dbo].[OrganizationUserUserDetails_ReadByOrganizationId]'; +END +GO + +IF OBJECT_ID('[dbo].[OrganizationUser_ReadByMinimumRole]') IS NOT NULL +BEGIN + EXECUTE sp_refreshsqlmodule N'[dbo].[OrganizationUser_ReadByMinimumRole]'; +END +GO