1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-24 17:17:40 +01:00
bitwarden-server/util/Migrator/DbScripts/2022-07-20_00_ProviderOrganizationListDetails.sql
Rui Tomé 169a4381dd
[EC-247] Add columns to provider portal clients table (#2136)
* Added migration script to alter ProviderOrganizationOrganizationDetailsView to add new columns UserCount, Seats and Plan

* Modified EF query ProviderOrganizationOrganizationDetailsReadByProviderIdQuery

* Modified model to output new view columns

* Updated view to count only active users

* Filtering the organization user count by only confirmed users
2022-07-28 09:31:03 +01:00

21 lines
568 B
Transact-SQL

-- Add columns 'UserCount', 'Seats' and 'Plan'
CREATE OR ALTER VIEW [dbo].[ProviderOrganizationOrganizationDetailsView]
AS
SELECT
PO.[Id],
PO.[ProviderId],
PO.[OrganizationId],
O.[Name] OrganizationName,
PO.[Key],
PO.[Settings],
PO.[CreationDate],
PO.[RevisionDate],
(SELECT COUNT(1) FROM [dbo].[OrganizationUser] OU WHERE OU.OrganizationId = PO.OrganizationId AND OU.Status = 2) UserCount,
O.[Seats],
O.[Plan]
FROM
[dbo].[ProviderOrganization] PO
LEFT JOIN
[dbo].[Organization] O ON O.[Id] = PO.[OrganizationId]
GO