1
0
mirror of https://github.com/bitwarden/server synced 2025-12-21 18:53:41 +00:00

fix errors

This commit is contained in:
jaasen-livefront
2025-11-13 18:58:50 -08:00
parent b29e22d189
commit a9e845d9bd
4 changed files with 26 additions and 56 deletions

View File

@@ -1,4 +1,4 @@
#nullable disable using Bit.Core.Entities;
namespace Bit.Core.Vault.Entities; namespace Bit.Core.Vault.Entities;
@@ -8,5 +8,6 @@ public class CipherArchive
public Guid UserId { get; set; } public Guid UserId { get; set; }
public DateTime ArchivedDate { get; set; } public DateTime ArchivedDate { get; set; }
public Cipher Cipher { get; set; } public Cipher? Cipher { get; set; }
public User? User { get; set; }
} }

View File

@@ -1,6 +1,4 @@
#nullable disable using Bit.Infrastructure.EntityFramework.Models;
using Bit.Infrastructure.EntityFramework.Models;
namespace Bit.Infrastructure.EntityFramework.Vault.Models; namespace Bit.Infrastructure.EntityFramework.Vault.Models;
@@ -9,6 +7,6 @@ public class CipherArchive
public Guid CipherId { get; set; } public Guid CipherId { get; set; }
public Guid UserId { get; set; } public Guid UserId { get; set; }
public DateTime ArchivedDate { get; set; } public DateTime ArchivedDate { get; set; }
public Cipher Cipher { get; set; } public Cipher? Cipher { get; set; }
public User User { get; set; } public User? User { get; set; }
} }

View File

@@ -1,55 +1,27 @@
IF OBJECT_ID(N'[dbo].[CipherArchive]', N'U') IS NULL CREATE TABLE [dbo].[CipherArchive]
BEGIN (
CREATE TABLE [dbo].[CipherArchive] [CipherId] UNIQUEIDENTIFIER NOT NULL,
( [UserId] UNIQUEIDENTIFIER NOT NULL,
[CipherId] UNIQUEIDENTIFIER NOT NULL, [ArchivedDate] DATETIME2(7) NOT NULL,
[UserId] UNIQUEIDENTIFIER NOT NULL, CONSTRAINT [PK_CipherArchive]
[ArchivedDate] DATETIME2(7) NOT NULL, PRIMARY KEY CLUSTERED ([CipherId], [UserId])
);
CONSTRAINT [PK_CipherArchive]
PRIMARY KEY CLUSTERED ([CipherId], [UserId])
);
END;
GO GO
IF NOT EXISTS ( ALTER TABLE [dbo].[CipherArchive]
SELECT 1 ADD CONSTRAINT [FK_CipherArchive_Cipher]
FROM sys.foreign_keys FOREIGN KEY ([CipherId])
WHERE name = N'FK_CipherArchive_Cipher' REFERENCES [dbo].[Cipher]([Id])
AND parent_object_id = OBJECT_ID(N'[dbo].[CipherArchive]', N'U') ON DELETE CASCADE;
)
BEGIN
ALTER TABLE [dbo].[CipherArchive]
ADD CONSTRAINT [FK_CipherArchive_Cipher]
FOREIGN KEY ([CipherId])
REFERENCES [dbo].[Cipher]([Id])
ON DELETE CASCADE;
END;
GO GO
IF NOT EXISTS ( ALTER TABLE [dbo].[CipherArchive]
SELECT 1 ADD CONSTRAINT [FK_CipherArchive_User]
FROM sys.foreign_keys FOREIGN KEY ([UserId])
WHERE name = N'FK_CipherArchive_User' REFERENCES [dbo].[User]([Id])
AND parent_object_id = OBJECT_ID(N'[dbo].[CipherArchive]', N'U') ON DELETE CASCADE;
)
BEGIN
ALTER TABLE [dbo].[CipherArchive]
ADD CONSTRAINT [FK_CipherArchive_User]
FOREIGN KEY ([UserId])
REFERENCES [dbo].[User]([Id])
ON DELETE CASCADE;
END;
GO GO
IF NOT EXISTS ( CREATE NONCLUSTERED INDEX [IX_CipherArchive_UserId]
SELECT 1 ON [dbo].[CipherArchive]([UserId]);
FROM sys.indexes
WHERE name = N'IX_CipherArchive_UserId'
AND object_id = OBJECT_ID(N'[dbo].[CipherArchive]', N'U')
)
BEGIN
CREATE NONCLUSTERED INDEX [IX_CipherArchive_UserId]
ON [dbo].[CipherArchive]([UserId]);
END;
GO GO

View File

@@ -42,7 +42,6 @@ BEGIN
END; END;
GO GO
-- Optional index for queries by user
IF NOT EXISTS ( IF NOT EXISTS (
SELECT 1 SELECT 1
FROM sys.indexes FROM sys.indexes