1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-29 13:25:17 +01:00
bitwarden-server/util/Migrator/DbScripts/2023-02-16_00_SelfHostedOrganizationDetails.sql

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
1.4 KiB
MySQL
Raw Normal View History

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