1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-22 12:15:36 +01:00
bitwarden-server/util/Migrator/DbScripts/2023-02-16_00_SelfHostedOrganizationDetails.sql
Thomas Rittson 4643f5960e
[EC-635] Extract organizationService.UpdateLicenseAsync to a command (#2408)
* move UpdateLicenseAsync from service to command
* create new SelfHostedOrganizationDetails view model and move license validation logic there
* move occupied seat count logic to database level
2023-02-24 07:54:19 +10:00

63 lines
1.4 KiB
Transact-SQL

CREATE OR ALTER PROCEDURE [dbo].[Group_ReadCountByOrganizationId]
@OrganizationId UNIQUEIDENTIFIER
AS
BEGIN
SET NOCOUNT ON
SELECT
COUNT(1)
FROM
[dbo].[Group]
WHERE
[OrganizationId] = @OrganizationId
END
GO
CREATE OR ALTER PROCEDURE [dbo].[OrganizationUser_ReadOccupiedSeatCountByOrganizationId]
@OrganizationId UNIQUEIDENTIFIER
AS
BEGIN
SET NOCOUNT ON
SELECT
COUNT(1)
FROM
[dbo].[OrganizationUserView]
WHERE
OrganizationId = @OrganizationId
AND Status >= 0 --Invited
END
GO
CREATE OR ALTER PROCEDURE [dbo].[Organization_ReadByLicenseKey]
@LicenseKey VARCHAR (100)
AS
BEGIN
SET NOCOUNT ON
SELECT
*
FROM
[dbo].[OrganizationView]
WHERE
[LicenseKey] = @LicenseKey
END
GO
CREATE OR ALTER PROCEDURE [dbo].[Organization_ReadSelfHostedDetailsById]
@Id UNIQUEIDENTIFIER
AS
BEGIN
SET NOCOUNT ON
EXEC [dbo].[Organization_ReadById] @Id
EXEC [dbo].[OrganizationUser_ReadOccupiedSeatCountByOrganizationId] @Id
EXEC [dbo].[Collection_ReadCountByOrganizationId] @Id
EXEC [dbo].[Group_ReadCountByOrganizationId] @Id
EXEC [dbo].[OrganizationUser_ReadByOrganizationId] @Id, NULL
EXEC [dbo].[Policy_ReadByOrganizationId] @Id
EXEC [dbo].[SsoConfig_ReadByOrganizationId] @Id
EXEC [dbo].[OrganizationConnection_ReadByOrganizationIdType] @Id, 2 --Scim connection type
END
GO