diff --git a/src/Sql/Sql.sqlproj b/src/Sql/Sql.sqlproj
index 01b7373489..c8788a3d7f 100644
--- a/src/Sql/Sql.sqlproj
+++ b/src/Sql/Sql.sqlproj
@@ -67,117 +67,117 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/src/Sql/dbo/Functions/CipherDetails.sql b/src/Sql/dbo/Functions/CipherDetails.sql
index d1c3d3b180..098cf121e3 100644
--- a/src/Sql/dbo/Functions/CipherDetails.sql
+++ b/src/Sql/dbo/Functions/CipherDetails.sql
@@ -21,4 +21,4 @@ SELECT
ELSE TRY_CONVERT(UNIQUEIDENTIFIER, JSON_VALUE(C.[Folders], CONCAT('$."', @UserId, '"')))
END [FolderId]
FROM
- [dbo].[Cipher] C
+ [dbo].[Cipher] C
\ No newline at end of file
diff --git a/src/Sql/dbo/Stored Procedures/Cipher_DeleteById.sql b/src/Sql/dbo/Stored Procedures/Cipher_DeleteById.sql
index 672368e39d..ca6f39a346 100644
--- a/src/Sql/dbo/Stored Procedures/Cipher_DeleteById.sql
+++ b/src/Sql/dbo/Stored Procedures/Cipher_DeleteById.sql
@@ -29,4 +29,4 @@ BEGIN
BEGIN
EXEC [dbo].[User_BumpAccountRevisionDate] @UserId
END
-END
+END
\ No newline at end of file
diff --git a/src/Sql/dbo/Stored Procedures/Folder_ReadByUserId.sql b/src/Sql/dbo/Stored Procedures/Folder_ReadByUserId.sql
index 79f3aa50f7..1244383ed7 100644
--- a/src/Sql/dbo/Stored Procedures/Folder_ReadByUserId.sql
+++ b/src/Sql/dbo/Stored Procedures/Folder_ReadByUserId.sql
@@ -10,4 +10,4 @@ BEGIN
[dbo].[FolderView]
WHERE
[UserId] = @UserId
-END
+END
\ No newline at end of file
diff --git a/src/Sql/dbo/Stored Procedures/Organization_Create.sql b/src/Sql/dbo/Stored Procedures/Organization_Create.sql
index 0212e1da4d..6e93749ec0 100644
--- a/src/Sql/dbo/Stored Procedures/Organization_Create.sql
+++ b/src/Sql/dbo/Stored Procedures/Organization_Create.sql
@@ -48,4 +48,4 @@ BEGIN
@CreationDate,
@RevisionDate
)
-END
+END
\ No newline at end of file
diff --git a/src/Sql/dbo/Stored Procedures/Organization_Update.sql b/src/Sql/dbo/Stored Procedures/Organization_Update.sql
index 1773e95cea..76636c4d63 100644
--- a/src/Sql/dbo/Stored Procedures/Organization_Update.sql
+++ b/src/Sql/dbo/Stored Procedures/Organization_Update.sql
@@ -34,4 +34,4 @@ BEGIN
[RevisionDate] = @RevisionDate
WHERE
[Id] = @Id
-END
+END
\ No newline at end of file
diff --git a/src/Sql/dbo/Stored Procedures/User_BumpAccountRevisionDate.sql b/src/Sql/dbo/Stored Procedures/User_BumpAccountRevisionDate.sql
index fe10429880..f17407b510 100644
--- a/src/Sql/dbo/Stored Procedures/User_BumpAccountRevisionDate.sql
+++ b/src/Sql/dbo/Stored Procedures/User_BumpAccountRevisionDate.sql
@@ -10,4 +10,4 @@ BEGIN
[AccountRevisionDate] = GETUTCDATE()
WHERE
[Id] = @Id
-END
+END
\ No newline at end of file
diff --git a/src/Sql/dbo/Stored Procedures/User_BumpAccountRevisionDateByOrganizationId.sql b/src/Sql/dbo/Stored Procedures/User_BumpAccountRevisionDateByOrganizationId.sql
index d2a7ca7672..a25d5b37d6 100644
--- a/src/Sql/dbo/Stored Procedures/User_BumpAccountRevisionDateByOrganizationId.sql
+++ b/src/Sql/dbo/Stored Procedures/User_BumpAccountRevisionDateByOrganizationId.sql
@@ -15,4 +15,4 @@ BEGIN
WHERE
OU.[OrganizationId] = @OrganizationId
AND OU.[Status] = 2 -- Confirmed
-END
+END
\ No newline at end of file
diff --git a/src/Sql/dbo/Stored Procedures/User_BumpAccountRevisionDateByOrganizationUserId.sql b/src/Sql/dbo/Stored Procedures/User_BumpAccountRevisionDateByOrganizationUserId.sql
index 4e793439b1..36a2064cbf 100644
--- a/src/Sql/dbo/Stored Procedures/User_BumpAccountRevisionDateByOrganizationUserId.sql
+++ b/src/Sql/dbo/Stored Procedures/User_BumpAccountRevisionDateByOrganizationUserId.sql
@@ -15,4 +15,4 @@ BEGIN
WHERE
OU.[Id] = @OrganizationUserId
AND OU.[Status] = 2 -- Confirmed
-END
+END
\ No newline at end of file
diff --git a/src/Sql/dbo/Stored Procedures/User_DeleteById.sql b/src/Sql/dbo/Stored Procedures/User_DeleteById.sql
index b6caa221c5..9ceac60338 100644
--- a/src/Sql/dbo/Stored Procedures/User_DeleteById.sql
+++ b/src/Sql/dbo/Stored Procedures/User_DeleteById.sql
@@ -36,4 +36,4 @@ BEGIN
[Id] = @Id
COMMIT TRANSACTION User_DeleteById
-END
+END
\ No newline at end of file
diff --git a/src/Sql/dbo/Stored Procedures/User_ReadAccountRevisionDateById.sql b/src/Sql/dbo/Stored Procedures/User_ReadAccountRevisionDateById.sql
index b7dab1dc4c..24a50b28b2 100644
--- a/src/Sql/dbo/Stored Procedures/User_ReadAccountRevisionDateById.sql
+++ b/src/Sql/dbo/Stored Procedures/User_ReadAccountRevisionDateById.sql
@@ -1,4 +1,5 @@
-CREATE PROCEDURE [dbo].[User_ReadAccountRevisionDateById]
+
+CREATE PROCEDURE [dbo].[User_ReadAccountRevisionDateById]
@Id UNIQUEIDENTIFIER
AS
BEGIN
diff --git a/src/Sql/dbo/Stored Procedures/User_UpdateEmailPassword.sql b/src/Sql/dbo/Stored Procedures/User_UpdateEmailPassword.sql
index fa368af81a..06d16d8d86 100644
--- a/src/Sql/dbo/Stored Procedures/User_UpdateEmailPassword.sql
+++ b/src/Sql/dbo/Stored Procedures/User_UpdateEmailPassword.sql
@@ -22,4 +22,4 @@ BEGIN
[AccountRevisionDate] = @RevisionDate
WHERE
[Id] = @Id
-END
+END
\ No newline at end of file
diff --git a/src/Sql/dbo/Tables/Cipher.sql b/src/Sql/dbo/Tables/Cipher.sql
index 0a75c3a4e8..c1f96bc7e1 100644
--- a/src/Sql/dbo/Tables/Cipher.sql
+++ b/src/Sql/dbo/Tables/Cipher.sql
@@ -14,11 +14,11 @@
GO
-CREATE NONCLUSTERED INDEX [IX_Cipher_UserId_Type]
- ON [dbo].[Cipher]([UserId] ASC, [Type] ASC);
+CREATE NONCLUSTERED INDEX [IX_Cipher_OrganizationId_Type]
+ ON [dbo].[Cipher]([OrganizationId] ASC, [Type] ASC) WHERE ([OrganizationId] IS NOT NULL);
GO
-CREATE NONCLUSTERED INDEX [IX_Cipher_OrganizationId_Type]
- ON [dbo].[Cipher]([OrganizationId] ASC, [Type] ASC)
- WHERE [OrganizationId] IS NOT NULL;
\ No newline at end of file
+CREATE NONCLUSTERED INDEX [IX_Cipher_UserId_Type]
+ ON [dbo].[Cipher]([UserId] ASC, [Type] ASC);
+
diff --git a/src/Sql/dbo/Tables/OrganizationUser.sql b/src/Sql/dbo/Tables/OrganizationUser.sql
index 4ba27ef0e1..ed7c0ce2f4 100644
--- a/src/Sql/dbo/Tables/OrganizationUser.sql
+++ b/src/Sql/dbo/Tables/OrganizationUser.sql
@@ -1,14 +1,14 @@
CREATE TABLE [dbo].[OrganizationUser] (
- [Id] UNIQUEIDENTIFIER NOT NULL,
- [OrganizationId] UNIQUEIDENTIFIER NOT NULL,
- [UserId] UNIQUEIDENTIFIER NULL,
- [Email] NVARCHAR (50) NULL,
- [Key] VARCHAR (MAX) NULL,
- [Status] TINYINT NOT NULL,
- [Type] TINYINT NOT NULL,
- [AccessAllSubvaults] BIT NOT NULL,
- [CreationDate] DATETIME2 (7) NOT NULL,
- [RevisionDate] DATETIME2 (7) NOT NULL,
+ [Id] UNIQUEIDENTIFIER NOT NULL,
+ [OrganizationId] UNIQUEIDENTIFIER NOT NULL,
+ [UserId] UNIQUEIDENTIFIER NULL,
+ [Email] NVARCHAR (50) NULL,
+ [Key] VARCHAR (MAX) NULL,
+ [Status] TINYINT NOT NULL,
+ [Type] TINYINT NOT NULL,
+ [AccessAllSubvaults] BIT NOT NULL,
+ [CreationDate] DATETIME2 (7) NOT NULL,
+ [RevisionDate] DATETIME2 (7) NOT NULL,
CONSTRAINT [PK_OrganizationUser] PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_OrganizationUser_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]) ON DELETE CASCADE,
CONSTRAINT [FK_OrganizationUser_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id])
diff --git a/src/Sql/dbo/Views/FolderView.sql b/src/Sql/dbo/Views/FolderView.sql
index 4a6fc91581..959248e302 100644
--- a/src/Sql/dbo/Views/FolderView.sql
+++ b/src/Sql/dbo/Views/FolderView.sql
@@ -3,4 +3,4 @@ AS
SELECT
*
FROM
- [dbo].[Folder]
+ [dbo].[Folder]
\ No newline at end of file
diff --git a/src/Sql/dbo/Views/UserView.sql b/src/Sql/dbo/Views/UserView.sql
index 82fa8a2c63..c8b77385a9 100644
--- a/src/Sql/dbo/Views/UserView.sql
+++ b/src/Sql/dbo/Views/UserView.sql
@@ -3,4 +3,4 @@ AS
SELECT
*
FROM
- [dbo].[User]
+ [dbo].[User]
\ No newline at end of file