Skip to content

Commit

Permalink
[PM-10365] Drop OrganizationUser AccessAll (bitwarden#4701)
Browse files Browse the repository at this point in the history
* Remove OrganizationUser.AccessAll

* Final database migrations
  • Loading branch information
eliykat authored Sep 24, 2024
1 parent 02fee8c commit f7bc5df
Show file tree
Hide file tree
Showing 23 changed files with 8,918 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ protected override void OnModelCreating(ModelBuilder builder)
var eOrganizationDomain = builder.Entity<OrganizationDomain>();
var aWebAuthnCredential = builder.Entity<WebAuthnCredential>();

// Shadow property configurations
builder.Entity<OrganizationUser>()
.Property<bool>("AccessAll")
.HasDefaultValue(false);
// Shadow property configurations go here

eCipher.Property(c => c.Id).ValueGeneratedNever();
eCollection.Property(c => c.Id).ValueGeneratedNever();
Expand Down
3 changes: 0 additions & 3 deletions src/Sql/dbo/Stored Procedures/OrganizationUser_Create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
@Key VARCHAR(MAX),
@Status SMALLINT,
@Type TINYINT,
@AccessAll BIT = 0,
@ExternalId NVARCHAR(300),
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7),
Expand All @@ -26,7 +25,6 @@ BEGIN
[Key],
[Status],
[Type],
[AccessAll],
[ExternalId],
[CreationDate],
[RevisionDate],
Expand All @@ -43,7 +41,6 @@ BEGIN
@Key,
@Status,
@Type,
@AccessAll,
@ExternalId,
@CreationDate,
@RevisionDate,
Expand Down
2 changes: 0 additions & 2 deletions src/Sql/dbo/Stored Procedures/OrganizationUser_CreateMany.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ BEGIN
[Key],
[Status],
[Type],
[AccessAll],
[ExternalId],
[CreationDate],
[RevisionDate],
Expand All @@ -29,7 +28,6 @@ BEGIN
OUI.[Key],
OUI.[Status],
OUI.[Type],
0, -- AccessAll will be removed shortly
OUI.[ExternalId],
OUI.[CreationDate],
OUI.[RevisionDate],
Expand Down
42 changes: 0 additions & 42 deletions src/Sql/dbo/Stored Procedures/OrganizationUser_CreateMany2.sql

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ CREATE PROCEDURE [dbo].[OrganizationUser_CreateWithCollections]
@Key VARCHAR(MAX),
@Status SMALLINT,
@Type TINYINT,
@AccessAll BIT = 0,
@ExternalId NVARCHAR(300),
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7),
Expand All @@ -18,7 +17,7 @@ AS
BEGIN
SET NOCOUNT ON

EXEC [dbo].[OrganizationUser_Create] @Id, @OrganizationId, @UserId, @Email, @Key, @Status, @Type, @AccessAll, @ExternalId, @CreationDate, @RevisionDate, @Permissions, @ResetPasswordKey, @AccessSecretsManager
EXEC [dbo].[OrganizationUser_Create] @Id, @OrganizationId, @UserId, @Email, @Key, @Status, @Type, @ExternalId, @CreationDate, @RevisionDate, @Permissions, @ResetPasswordKey, @AccessSecretsManager

;WITH [AvailableCollectionsCTE] AS(
SELECT
Expand Down
2 changes: 0 additions & 2 deletions src/Sql/dbo/Stored Procedures/OrganizationUser_Update.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
@Key VARCHAR(MAX),
@Status SMALLINT,
@Type TINYINT,
@AccessAll BIT = 0,
@ExternalId NVARCHAR(300),
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7),
Expand All @@ -26,7 +25,6 @@ BEGIN
[Key] = @Key,
[Status] = @Status,
[Type] = @Type,
[AccessAll] = @AccessAll,
[ExternalId] = @ExternalId,
[CreationDate] = @CreationDate,
[RevisionDate] = @RevisionDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ BEGIN
[Key] = OUI.[Key],
[Status] = OUI.[Status],
[Type] = OUI.[Type],
[AccessAll] = 0, -- AccessAll will be removed shortly
[ExternalId] = OUI.[ExternalId],
[CreationDate] = OUI.[CreationDate],
[RevisionDate] = OUI.[RevisionDate],
Expand Down
34 changes: 0 additions & 34 deletions src/Sql/dbo/Stored Procedures/OrganizationUser_UpdateMany2.sql

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
@Key VARCHAR(MAX),
@Status SMALLINT,
@Type TINYINT,
@AccessAll BIT = 0,
@ExternalId NVARCHAR(300),
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7),
Expand All @@ -18,7 +17,7 @@ AS
BEGIN
SET NOCOUNT ON

EXEC [dbo].[OrganizationUser_Update] @Id, @OrganizationId, @UserId, @Email, @Key, @Status, @Type, @AccessAll, @ExternalId, @CreationDate, @RevisionDate, @Permissions, @ResetPasswordKey, @AccessSecretsManager
EXEC [dbo].[OrganizationUser_Update] @Id, @OrganizationId, @UserId, @Email, @Key, @Status, @Type, @ExternalId, @CreationDate, @RevisionDate, @Permissions, @ResetPasswordKey, @AccessSecretsManager
-- Update
UPDATE
[Target]
Expand Down
6 changes: 2 additions & 4 deletions src/Sql/dbo/Tables/OrganizationUser.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
[ResetPasswordKey] VARCHAR (MAX) NULL,
[Status] SMALLINT NOT NULL,
[Type] TINYINT NOT NULL,
[AccessAll] BIT NOT NULL,
[ExternalId] NVARCHAR (300) NULL,
[CreationDate] DATETIME2 (7) NOT NULL,
[RevisionDate] DATETIME2 (7) NOT NULL,
Expand All @@ -20,9 +19,8 @@


GO
CREATE NONCLUSTERED INDEX [IX_OrganizationUser_UserIdOrganizationIdStatus]
ON [dbo].[OrganizationUser]([UserId] ASC, [OrganizationId] ASC, [Status] ASC)
INCLUDE ([AccessAll]);
CREATE NONCLUSTERED INDEX [IX_OrganizationUser_UserIdOrganizationIdStatusV2]
ON [dbo].[OrganizationUser]([UserId] ASC, [OrganizationId] ASC, [Status] ASC);


GO
Expand Down
16 changes: 0 additions & 16 deletions src/Sql/dbo/User Defined Types/OrganizationUserType2.sql

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- Finalise removal of OrganizationUser.AccessAll column
-- Add default column value
-- Sprocs already have default value for rollback purposes, this just supports dropping the column itself

IF OBJECT_ID('[dbo].[DF_OrganizationUser_AccessAll]', 'D') IS NULL
AND COL_LENGTH('[dbo].[OrganizationUser]', 'AccessAll') IS NOT NULL
BEGIN
ALTER TABLE [dbo].[OrganizationUser]
ADD CONSTRAINT [DF_OrganizationUser_AccessAll] DEFAULT (0) FOR [AccessAll];
END
GO
Loading

0 comments on commit f7bc5df

Please sign in to comment.