diff --git a/src/Core/Repositories/SqlServer/CipherRepository.cs b/src/Core/Repositories/SqlServer/CipherRepository.cs
index ff9e1f96da..750c273847 100644
--- a/src/Core/Repositories/SqlServer/CipherRepository.cs
+++ b/src/Core/Repositories/SqlServer/CipherRepository.cs
@@ -41,6 +41,7 @@ namespace Bit.Core.Repositories.SqlServer
cmd.Parameters.Add("@Email", SqlDbType.NVarChar).Value = user.Email;
cmd.Parameters.Add("@MasterPassword", SqlDbType.NVarChar).Value = user.MasterPassword;
cmd.Parameters.Add("@SecurityStamp", SqlDbType.NVarChar).Value = user.SecurityStamp;
+ cmd.Parameters.Add("@RevisionDate", SqlDbType.DateTime2).Value = user.RevisionDate;
cmd.ExecuteNonQuery();
}
@@ -92,9 +93,9 @@ namespace Bit.Core.Repositories.SqlServer
UPDATE
[dbo].[Folder]
SET
- [UserId] = TF.[UserId],
+ -- Do not update [UserId]
[Name] = TF.[Name],
- [CreationDate] = TF.[CreationDate],
+ -- Do not update TF.[CreationDate]
[RevisionDate] = TF.[RevisionDate]
FROM
[dbo].[Folder] F
@@ -106,14 +107,14 @@ namespace Bit.Core.Repositories.SqlServer
UPDATE
[dbo].[Site]
SET
- [UserId] = TS.[UserId],
- [FolderId] = TS.[FolderId],
+ -- Do not update [UserId]
+ -- Do not update [FolderId]
[Name] = TS.[Name],
[Uri] = TS.[Uri],
[Username] = TS.[Username],
[Password] = TS.[Password],
[Notes] = TS.[Notes],
- [CreationDate] = TS.[CreationDate],
+ -- Do not update [CreationDate]
[RevisionDate] = TS.[RevisionDate]
FROM
[dbo].[Site] S
diff --git a/src/Core/Repositories/SqlServer/Models/UserTableModel.cs b/src/Core/Repositories/SqlServer/Models/UserTableModel.cs
index 371ced193f..8806ce9c8e 100644
--- a/src/Core/Repositories/SqlServer/Models/UserTableModel.cs
+++ b/src/Core/Repositories/SqlServer/Models/UserTableModel.cs
@@ -21,6 +21,7 @@ namespace Bit.Core.Repositories.SqlServer.Models
TwoFactorProvider = user.TwoFactorProvider;
AuthenticatorKey = user.AuthenticatorKey;
CreationDate = user.CreationDate;
+ RevisionDate = user.RevisionDate;
}
public Guid Id { get; set; }
@@ -34,6 +35,7 @@ namespace Bit.Core.Repositories.SqlServer.Models
public TwoFactorProvider? TwoFactorProvider { get; set; }
public string AuthenticatorKey { get; set; }
public DateTime CreationDate { get; set; }
+ public DateTime RevisionDate { get; set; }
public User ToDomain()
{
@@ -49,7 +51,8 @@ namespace Bit.Core.Repositories.SqlServer.Models
TwoFactorEnabled = TwoFactorEnabled,
TwoFactorProvider = TwoFactorProvider,
AuthenticatorKey = AuthenticatorKey,
- CreationDate = CreationDate
+ CreationDate = CreationDate,
+ RevisionDate = RevisionDate
};
}
}
diff --git a/src/Sql/Sql.sqlproj b/src/Sql/Sql.sqlproj
index da563843b1..009c63fee7 100644
--- a/src/Sql/Sql.sqlproj
+++ b/src/Sql/Sql.sqlproj
@@ -68,9 +68,9 @@
-
+
diff --git a/src/Sql/dbo/Stored Procedures/User_Create.sql b/src/Sql/dbo/Stored Procedures/User_Create.sql
index 480726cac1..0084f1d28d 100644
--- a/src/Sql/dbo/Stored Procedures/User_Create.sql
+++ b/src/Sql/dbo/Stored Procedures/User_Create.sql
@@ -9,7 +9,8 @@
@TwoFactorEnabled BIT,
@TwoFactorProvider TINYINT,
@AuthenticatorKey NVARCHAR(50),
- @CreationDate DATETIME2(7)
+ @CreationDate DATETIME2(7),
+ @RevisionDate DATETIME2(7)
AS
BEGIN
INSERT INTO [dbo].[User]
@@ -24,7 +25,8 @@ BEGIN
[TwoFactorEnabled],
[TwoFactorProvider],
[AuthenticatorKey],
- [CreationDate]
+ [CreationDate],
+ [RevisionDate]
)
VALUES
(
@@ -38,6 +40,7 @@ BEGIN
@TwoFactorEnabled,
@TwoFactorProvider,
@AuthenticatorKey,
- @CreationDate
+ @CreationDate,
+ @RevisionDate
)
END
diff --git a/src/Sql/dbo/Stored Procedures/User_Update.sql b/src/Sql/dbo/Stored Procedures/User_Update.sql
index 99b45d3352..019f7ed5df 100644
--- a/src/Sql/dbo/Stored Procedures/User_Update.sql
+++ b/src/Sql/dbo/Stored Procedures/User_Update.sql
@@ -9,7 +9,8 @@
@TwoFactorEnabled BIT,
@TwoFactorProvider TINYINT,
@AuthenticatorKey NVARCHAR(50),
- @CreationDate DATETIME2(7)
+ @CreationDate DATETIME2(7),
+ @RevisionDate DATETIME2(7)
AS
BEGIN
UPDATE
@@ -24,7 +25,8 @@ BEGIN
[TwoFactorEnabled] = @TwoFactorEnabled,
[TwoFactorProvider] = TwoFactorProvider,
[AuthenticatorKey] = @AuthenticatorKey,
- [CreationDate] = @CreationDate
+ [CreationDate] = @CreationDate,
+ [RevisionDate] = @RevisionDate
WHERE
[Id] = @Id
END
diff --git a/src/Sql/dbo/Stored Procedures/User_UpdateEmailPassword.sql b/src/Sql/dbo/Stored Procedures/User_UpdateEmailPassword.sql
index 42e6712245..d3c77a2589 100644
--- a/src/Sql/dbo/Stored Procedures/User_UpdateEmailPassword.sql
+++ b/src/Sql/dbo/Stored Procedures/User_UpdateEmailPassword.sql
@@ -2,7 +2,8 @@
@Id UNIQUEIDENTIFIER,
@Email NVARCHAR(50),
@MasterPassword NVARCHAR(300),
- @SecurityStamp NVARCHAR(50)
+ @SecurityStamp NVARCHAR(50),
+ @RevisionDate DATETIME2(7)
AS
BEGIN
UPDATE
@@ -10,7 +11,8 @@ BEGIN
SET
[Email] = @Email,
[MasterPassword] = @MasterPassword,
- [SecurityStamp] = @SecurityStamp
+ [SecurityStamp] = @SecurityStamp,
+ [RevisionDate] = @RevisionDate
WHERE
[Id] = @Id
END
diff --git a/src/Sql/dbo/Tables/User.sql b/src/Sql/dbo/Tables/User.sql
index bb882e0d5c..760b85f1ef 100644
--- a/src/Sql/dbo/Tables/User.sql
+++ b/src/Sql/dbo/Tables/User.sql
@@ -10,6 +10,7 @@
[TwoFactorProvider] TINYINT NULL,
[AuthenticatorKey] NVARCHAR (50) NULL,
[CreationDate] DATETIME2 (7) NOT NULL,
+ [RevisionDate] DATETIME2 (7) NOT NULL,
CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED ([Id] ASC)
);