1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 21:18:13 -05:00

Updated PR comments, changed smart defaults for behavior, updated Cipher table index

This commit is contained in:
Chad Scharf 2020-03-27 10:23:37 -04:00
parent bc46eccf70
commit 55b937ff68
11 changed files with 26 additions and 22 deletions

View File

@ -23,8 +23,8 @@ namespace Bit.Core.Repositories
Task UpdatePartialAsync(Guid id, Guid userId, Guid? folderId, bool favorite); Task UpdatePartialAsync(Guid id, Guid userId, Guid? folderId, bool favorite);
Task UpdateAttachmentAsync(CipherAttachment attachment); Task UpdateAttachmentAsync(CipherAttachment attachment);
Task DeleteAttachmentAsync(Guid cipherId, string attachmentId); Task DeleteAttachmentAsync(Guid cipherId, string attachmentId);
Task DeleteAsync(Cipher obj, bool permanent = false); Task DeleteAsync(Cipher obj, bool permanent = true);
Task DeleteAsync(IEnumerable<Guid> ids, Guid userId, bool permanent = false); Task DeleteAsync(IEnumerable<Guid> ids, Guid userId, bool permanent = true);
Task MoveAsync(IEnumerable<Guid> ids, Guid? folderId, Guid userId); Task MoveAsync(IEnumerable<Guid> ids, Guid? folderId, Guid userId);
Task DeleteByUserIdAsync(Guid userId); Task DeleteByUserIdAsync(Guid userId);
Task DeleteByOrganizationIdAsync(Guid organizationId); Task DeleteByOrganizationIdAsync(Guid organizationId);

View File

@ -215,9 +215,9 @@ namespace Bit.Core.Repositories.SqlServer
} }
} }
public async Task DeleteAsync(Cipher obj, bool permanent = false) public async Task DeleteAsync(Cipher obj, bool permanent = true)
{ {
using (var connection = new SqlConnection(ConnectionString)) using(var connection = new SqlConnection(ConnectionString))
{ {
var results = await connection.ExecuteAsync( var results = await connection.ExecuteAsync(
$"[{Schema}].[Cipher_DeleteById]", $"[{Schema}].[Cipher_DeleteById]",
@ -226,7 +226,7 @@ namespace Bit.Core.Repositories.SqlServer
} }
} }
public async Task DeleteAsync(IEnumerable<Guid> ids, Guid userId, bool permanent = false) public async Task DeleteAsync(IEnumerable<Guid> ids, Guid userId, bool permanent = true)
{ {
using(var connection = new SqlConnection(ConnectionString)) using(var connection = new SqlConnection(ConnectionString))
{ {

View File

@ -1,6 +1,6 @@
CREATE PROCEDURE [dbo].[CipherDetails_ReadByUserId] CREATE PROCEDURE [dbo].[CipherDetails_ReadByUserId]
@UserId UNIQUEIDENTIFIER, @UserId UNIQUEIDENTIFIER,
@Deleted BIT = 0 @Deleted BIT
AS AS
BEGIN BEGIN
SET NOCOUNT ON SET NOCOUNT ON

View File

@ -1,6 +1,6 @@
CREATE PROCEDURE [dbo].[CipherDetails_ReadWithoutOrganizationsByUserId] CREATE PROCEDURE [dbo].[CipherDetails_ReadWithoutOrganizationsByUserId]
@UserId UNIQUEIDENTIFIER, @UserId UNIQUEIDENTIFIER,
@Deleted BIT = 0 @Deleted BIT
AS AS
BEGIN BEGIN
SET NOCOUNT ON SET NOCOUNT ON

View File

@ -1,6 +1,6 @@
CREATE PROCEDURE [dbo].[CipherOrganizationDetails_ReadById] CREATE PROCEDURE [dbo].[CipherOrganizationDetails_ReadById]
@Id UNIQUEIDENTIFIER, @Id UNIQUEIDENTIFIER,
@Deleted BIT = 0 @Deleted BIT
AS AS
BEGIN BEGIN
SET NOCOUNT ON SET NOCOUNT ON

View File

@ -1,7 +1,7 @@
CREATE PROCEDURE [dbo].[Cipher_Delete] CREATE PROCEDURE [dbo].[Cipher_Delete]
@Ids AS [dbo].[GuidIdArray] READONLY, @Ids AS [dbo].[GuidIdArray] READONLY,
@UserId AS UNIQUEIDENTIFIER, @UserId AS UNIQUEIDENTIFIER,
@Permanent AS BIT = 0 @Permanent AS BIT
AS AS
BEGIN BEGIN
SET NOCOUNT ON SET NOCOUNT ON

View File

@ -1,6 +1,6 @@
CREATE PROCEDURE [dbo].[Cipher_DeleteById] CREATE PROCEDURE [dbo].[Cipher_DeleteById]
@Id UNIQUEIDENTIFIER, @Id UNIQUEIDENTIFIER,
@Permanent AS BIT = 0 @Permanent AS BIT
WITH RECOMPILE WITH RECOMPILE
AS AS
BEGIN BEGIN

View File

@ -1,6 +1,6 @@
CREATE PROCEDURE [dbo].[Cipher_ReadByOrganizationId] CREATE PROCEDURE [dbo].[Cipher_ReadByOrganizationId]
@OrganizationId UNIQUEIDENTIFIER, @OrganizationId UNIQUEIDENTIFIER,
@Deleted BIT = 0 @Deleted BIT
AS AS
BEGIN BEGIN
SET NOCOUNT ON SET NOCOUNT ON

View File

@ -19,7 +19,7 @@
GO GO
CREATE NONCLUSTERED INDEX [IX_Cipher_UserId_OrganizationId_IncludeAll] CREATE NONCLUSTERED INDEX [IX_Cipher_UserId_OrganizationId_IncludeAll]
ON [dbo].[Cipher]([UserId] ASC, [OrganizationId] ASC) ON [dbo].[Cipher]([UserId] ASC, [OrganizationId] ASC)
INCLUDE ([Type], [Data], [Favorites], [Folders], [Attachments], [CreationDate], [RevisionDate]); INCLUDE ([Type], [Data], [Favorites], [Folders], [Attachments], [CreationDate], [RevisionDate], [DeletedDate]);
GO GO

View File

@ -67,7 +67,7 @@ GO
CREATE PROCEDURE [dbo].[CipherDetails_ReadWithoutOrganizationsByUserId] CREATE PROCEDURE [dbo].[CipherDetails_ReadWithoutOrganizationsByUserId]
@UserId UNIQUEIDENTIFIER, @UserId UNIQUEIDENTIFIER,
@Deleted BIT = 0 @Deleted BIT
AS AS
BEGIN BEGIN
SET NOCOUNT ON SET NOCOUNT ON
@ -96,7 +96,7 @@ GO
CREATE PROCEDURE [dbo].[Cipher_ReadByOrganizationId] CREATE PROCEDURE [dbo].[Cipher_ReadByOrganizationId]
@OrganizationId UNIQUEIDENTIFIER, @OrganizationId UNIQUEIDENTIFIER,
@Deleted BIT = 0 @Deleted BIT
AS AS
BEGIN BEGIN
SET NOCOUNT ON SET NOCOUNT ON
@ -124,7 +124,7 @@ GO
CREATE PROCEDURE [dbo].[CipherOrganizationDetails_ReadById] CREATE PROCEDURE [dbo].[CipherOrganizationDetails_ReadById]
@Id UNIQUEIDENTIFIER, @Id UNIQUEIDENTIFIER,
@Deleted BIT = 0 @Deleted BIT
AS AS
BEGIN BEGIN
SET NOCOUNT ON SET NOCOUNT ON
@ -157,7 +157,7 @@ GO
CREATE PROCEDURE [dbo].[CipherDetails_ReadByUserId] CREATE PROCEDURE [dbo].[CipherDetails_ReadByUserId]
@UserId UNIQUEIDENTIFIER, @UserId UNIQUEIDENTIFIER,
@Deleted BIT = 0 @Deleted BIT
AS AS
BEGIN BEGIN
SET NOCOUNT ON SET NOCOUNT ON
@ -181,7 +181,7 @@ GO
CREATE PROCEDURE [dbo].[Cipher_Delete] CREATE PROCEDURE [dbo].[Cipher_Delete]
@Ids AS [dbo].[GuidIdArray] READONLY, @Ids AS [dbo].[GuidIdArray] READONLY,
@UserId AS UNIQUEIDENTIFIER, @UserId AS UNIQUEIDENTIFIER,
@Permanent AS BIT = 0 @Permanent AS BIT
AS AS
BEGIN BEGIN
SET NOCOUNT ON SET NOCOUNT ON
@ -282,7 +282,7 @@ GO
CREATE PROCEDURE [dbo].[Cipher_DeleteById] CREATE PROCEDURE [dbo].[Cipher_DeleteById]
@Id UNIQUEIDENTIFIER, @Id UNIQUEIDENTIFIER,
@Permanent AS BIT = 0 @Permanent AS BIT
WITH RECOMPILE WITH RECOMPILE
AS AS
BEGIN BEGIN
@ -481,3 +481,11 @@ BEGIN
EXECUTE sp_refreshsqlmodule N'[dbo].[Cipher_UpdateWithCollections]'; EXECUTE sp_refreshsqlmodule N'[dbo].[Cipher_UpdateWithCollections]';
END END
GO GO
DROP INDEX IF EXISTS [IX_Cipher_UserId_OrganizationId_IncludeAll]
ON [dbo].[Cipher];
GO
CREATE NONCLUSTERED INDEX [IX_Cipher_UserId_OrganizationId_IncludeAll]
ON [dbo].[Cipher]([UserId] ASC, [OrganizationId] ASC)
INCLUDE([Type], [Data], [Favorites], [Folders], [Attachments], [CreationDate], [RevisionDate], [DeletedDate]);
GO

View File

@ -9,10 +9,6 @@
<EmbeddedResource Include="DbScripts\**\*.sql" /> <EmbeddedResource Include="DbScripts\**\*.sql" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Remove="DbScripts\2020-03-26_00_CipherSoftDelete.sql" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="dbup-sqlserver" Version="4.2.0" /> <PackageReference Include="dbup-sqlserver" Version="4.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.2" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.2" />