mirror of
https://github.com/bitwarden/server.git
synced 2025-07-07 02:52:50 -05:00
Split LimitCollectionCreationDeletion
into two database columns (#4709)
* Add new columns to `dbo.Organization` & its references * Feed existing data into new `dbo.Organization` column * Update Entity Framework database definitions * Move new EF columns out of the core entity definition * Generate Entity Framework migrations * Feed existing data into new `Organization` Entity Framework columns * Add a where clause to SQL migration
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
CREATE PROCEDURE [dbo].[Organization_Create]
|
||||
CREATE PROCEDURE [dbo].[Organization_Create]
|
||||
@Id UNIQUEIDENTIFIER OUTPUT,
|
||||
@Identifier NVARCHAR(50),
|
||||
@Name NVARCHAR(50),
|
||||
@ -51,12 +51,17 @@
|
||||
@MaxAutoscaleSmSeats INT= null,
|
||||
@MaxAutoscaleSmServiceAccounts INT = null,
|
||||
@SecretsManagerBeta BIT = 0,
|
||||
@LimitCollectionCreationDeletion BIT = 0,
|
||||
@LimitCollectionCreationDeletion BIT = NULL, -- Deprecated https://bitwarden.atlassian.net/browse/PM-10863
|
||||
@LimitCollectionCreation BIT = NULL,
|
||||
@LimitCollectionDeletion BIT = NULL,
|
||||
@AllowAdminAccessToAllCollectionItems BIT = 0
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SET @LimitCollectionCreation = COALESCE(@LimitCollectionCreation, @LimitCollectionCreationDeletion, 0);
|
||||
SET @LimitCollectionDeletion = COALESCE(@LimitCollectionDeletion, @LimitCollectionCreationDeletion, 0);
|
||||
|
||||
INSERT INTO [dbo].[Organization]
|
||||
(
|
||||
[Id],
|
||||
@ -111,7 +116,9 @@ BEGIN
|
||||
[MaxAutoscaleSmSeats],
|
||||
[MaxAutoscaleSmServiceAccounts],
|
||||
[SecretsManagerBeta],
|
||||
[LimitCollectionCreationDeletion],
|
||||
[LimitCollectionCreationDeletion], -- Deprecated https://bitwarden.atlassian.net/browse/PM-10863
|
||||
[LimitCollectionCreation],
|
||||
[LimitCollectionDeletion],
|
||||
[AllowAdminAccessToAllCollectionItems]
|
||||
)
|
||||
VALUES
|
||||
@ -168,7 +175,9 @@ BEGIN
|
||||
@MaxAutoscaleSmSeats,
|
||||
@MaxAutoscaleSmServiceAccounts,
|
||||
@SecretsManagerBeta,
|
||||
@LimitCollectionCreationDeletion,
|
||||
COALESCE(@LimitCollectionCreation, @LimitCollectionDeletion, 0), -- Deprecated https://bitwarden.atlassian.net/browse/PM-10863)
|
||||
@LimitCollectionCreation,
|
||||
@LimitCollectionDeletion,
|
||||
@AllowAdminAccessToAllCollectionItems
|
||||
)
|
||||
END
|
||||
|
@ -1,4 +1,4 @@
|
||||
CREATE PROCEDURE [dbo].[Organization_ReadAbilities]
|
||||
CREATE PROCEDURE [dbo].[Organization_ReadAbilities]
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
@ -21,7 +21,9 @@ BEGIN
|
||||
[UseResetPassword],
|
||||
[UsePolicies],
|
||||
[Enabled],
|
||||
[LimitCollectionCreationDeletion],
|
||||
[LimitCollectionCreationDeletion], -- Deprecated https://bitwarden.atlassian.net/browse/PM-10863
|
||||
[LimitCollectionCreation],
|
||||
[LimitCollectionDeletion],
|
||||
[AllowAdminAccessToAllCollectionItems]
|
||||
FROM
|
||||
[dbo].[Organization]
|
||||
|
@ -1,4 +1,4 @@
|
||||
CREATE PROCEDURE [dbo].[Organization_Update]
|
||||
CREATE PROCEDURE [dbo].[Organization_Update]
|
||||
@Id UNIQUEIDENTIFIER,
|
||||
@Identifier NVARCHAR(50),
|
||||
@Name NVARCHAR(50),
|
||||
@ -51,12 +51,17 @@
|
||||
@MaxAutoscaleSmSeats INT = null,
|
||||
@MaxAutoscaleSmServiceAccounts INT = null,
|
||||
@SecretsManagerBeta BIT = 0,
|
||||
@LimitCollectionCreationDeletion BIT = 0,
|
||||
@LimitCollectionCreationDeletion BIT = null, -- Deprecated https://bitwarden.atlassian.net/browse/PM-10863
|
||||
@LimitCollectionCreation BIT = null,
|
||||
@LimitCollectionDeletion BIT = null,
|
||||
@AllowAdminAccessToAllCollectionItems BIT = 0
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SET @LimitCollectionCreation = COALESCE(@LimitCollectionCreation, @LimitCollectionCreationDeletion, 0);
|
||||
SET @LimitCollectionDeletion = COALESCE(@LimitCollectionDeletion, @LimitCollectionCreationDeletion, 0);
|
||||
|
||||
UPDATE
|
||||
[dbo].[Organization]
|
||||
SET
|
||||
@ -111,7 +116,9 @@ BEGIN
|
||||
[MaxAutoscaleSmSeats] = @MaxAutoscaleSmSeats,
|
||||
[MaxAutoscaleSmServiceAccounts] = @MaxAutoscaleSmServiceAccounts,
|
||||
[SecretsManagerBeta] = @SecretsManagerBeta,
|
||||
[LimitCollectionCreationDeletion] = @LimitCollectionCreationDeletion,
|
||||
[LimitCollectionCreationDeletion] = COALESCE(@LimitCollectionCreation, @LimitCollectionDeletion, 0),
|
||||
[LimitCollectionCreation] = @LimitCollectionCreation,
|
||||
[LimitCollectionDeletion] = @LimitCollectionDeletion,
|
||||
[AllowAdminAccessToAllCollectionItems] = @AllowAdminAccessToAllCollectionItems
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
|
@ -1,4 +1,4 @@
|
||||
CREATE TABLE [dbo].[Organization] (
|
||||
CREATE TABLE [dbo].[Organization] (
|
||||
[Id] UNIQUEIDENTIFIER NOT NULL,
|
||||
[Identifier] NVARCHAR (50) NULL,
|
||||
[Name] NVARCHAR (50) NOT NULL,
|
||||
@ -52,6 +52,8 @@
|
||||
[MaxAutoscaleSmServiceAccounts] INT NULL,
|
||||
[SecretsManagerBeta] BIT NOT NULL CONSTRAINT [DF_Organization_SecretsManagerBeta] DEFAULT (0),
|
||||
[LimitCollectionCreationDeletion] BIT NOT NULL CONSTRAINT [DF_Organization_LimitCollectionCreationDeletion] DEFAULT (0),
|
||||
[LimitCollectionCreation] BIT NOT NULL CONSTRAINT [DF_Organization_LimitCollectionCreation] DEFAULT (0),
|
||||
[LimitCollectionDeletion] BIT NOT NULL CONSTRAINT [DF_Organization_LimitCollectionDeletion] DEFAULT (0),
|
||||
[AllowAdminAccessToAllCollectionItems] BIT NOT NULL CONSTRAINT [DF_Organization_AllowAdminAccessToAllCollectionItems] DEFAULT (0),
|
||||
CONSTRAINT [PK_Organization] PRIMARY KEY CLUSTERED ([Id] ASC)
|
||||
);
|
||||
|
@ -1,4 +1,4 @@
|
||||
CREATE VIEW [dbo].[OrganizationUserOrganizationDetailsView]
|
||||
CREATE VIEW [dbo].[OrganizationUserOrganizationDetailsView]
|
||||
AS
|
||||
SELECT
|
||||
OU.[UserId],
|
||||
@ -46,7 +46,9 @@ SELECT
|
||||
O.[UsePasswordManager],
|
||||
O.[SmSeats],
|
||||
O.[SmServiceAccounts],
|
||||
O.[LimitCollectionCreationDeletion],
|
||||
O.[LimitCollectionCreationDeletion], -- Deprecated https://bitwarden.atlassian.net/browse/PM-10863
|
||||
O.[LimitCollectionCreation],
|
||||
O.[LimitCollectionDeletion],
|
||||
O.[AllowAdminAccessToAllCollectionItems]
|
||||
FROM
|
||||
[dbo].[OrganizationUser] OU
|
||||
|
@ -1,4 +1,4 @@
|
||||
CREATE VIEW [dbo].[ProviderUserProviderOrganizationDetailsView]
|
||||
CREATE VIEW [dbo].[ProviderUserProviderOrganizationDetailsView]
|
||||
AS
|
||||
SELECT
|
||||
PU.[UserId],
|
||||
@ -32,7 +32,9 @@ SELECT
|
||||
PU.[Id] ProviderUserId,
|
||||
P.[Name] ProviderName,
|
||||
O.[PlanType],
|
||||
O.[LimitCollectionCreationDeletion],
|
||||
O.[LimitCollectionCreationDeletion], -- Deprecated https://bitwarden.atlassian.net/browse/PM-10863
|
||||
O.[LimitCollectionCreation],
|
||||
O.[LimitCollectionDeletion],
|
||||
O.[AllowAdminAccessToAllCollectionItems]
|
||||
FROM
|
||||
[dbo].[ProviderUser] PU
|
||||
|
Reference in New Issue
Block a user