mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
[PM-14590] Modify Notification database table (#5361)
* Added notification type enum Added option type to entity * created migration files * made sprocs backward compatible * made sprocs backward compatible * Fixed linting * Altered table to require an optional taskId * formatted code * Added foreignkey * Formatted code * fixed order
This commit is contained in:
@ -20,6 +20,7 @@ public class Notification : ITableObject<Guid>
|
||||
public string? Body { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
public Guid? TaskId { get; set; }
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
|
@ -30,6 +30,10 @@ public class NotificationEntityTypeConfiguration : IEntityTypeConfiguration<Noti
|
||||
.HasIndex(n => n.UserId)
|
||||
.IsClustered(false);
|
||||
|
||||
builder
|
||||
.HasIndex(n => n.TaskId)
|
||||
.IsClustered(false);
|
||||
|
||||
builder.ToTable(nameof(Notification));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using AutoMapper;
|
||||
using Bit.Infrastructure.EntityFramework.AdminConsole.Models;
|
||||
using Bit.Infrastructure.EntityFramework.Models;
|
||||
using Bit.Infrastructure.EntityFramework.Vault.Models;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.NotificationCenter.Models;
|
||||
|
||||
@ -8,6 +9,7 @@ public class Notification : Core.NotificationCenter.Entities.Notification
|
||||
{
|
||||
public virtual User User { get; set; }
|
||||
public virtual Organization Organization { get; set; }
|
||||
public virtual SecurityTask Task { get; set; }
|
||||
}
|
||||
|
||||
public class NotificationMapperProfile : Profile
|
||||
|
@ -8,7 +8,8 @@ CREATE PROCEDURE [dbo].[Notification_Create]
|
||||
@Title NVARCHAR(256),
|
||||
@Body NVARCHAR(MAX),
|
||||
@CreationDate DATETIME2(7),
|
||||
@RevisionDate DATETIME2(7)
|
||||
@RevisionDate DATETIME2(7),
|
||||
@TaskId UNIQUEIDENTIFIER = NULL
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
@ -23,7 +24,8 @@ BEGIN
|
||||
[Title],
|
||||
[Body],
|
||||
[CreationDate],
|
||||
[RevisionDate]
|
||||
[RevisionDate],
|
||||
[TaskId]
|
||||
)
|
||||
VALUES (
|
||||
@Id,
|
||||
@ -35,6 +37,7 @@ BEGIN
|
||||
@Title,
|
||||
@Body,
|
||||
@CreationDate,
|
||||
@RevisionDate
|
||||
@RevisionDate,
|
||||
@TaskId
|
||||
)
|
||||
END
|
||||
|
@ -8,7 +8,8 @@ CREATE PROCEDURE [dbo].[Notification_Update]
|
||||
@Title NVARCHAR(256),
|
||||
@Body NVARCHAR(MAX),
|
||||
@CreationDate DATETIME2(7),
|
||||
@RevisionDate DATETIME2(7)
|
||||
@RevisionDate DATETIME2(7),
|
||||
@TaskId UNIQUEIDENTIFIER = NULL
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
@ -22,6 +23,7 @@ BEGIN
|
||||
[Title] = @Title,
|
||||
[Body] = @Body,
|
||||
[CreationDate] = @CreationDate,
|
||||
[RevisionDate] = @RevisionDate
|
||||
[RevisionDate] = @RevisionDate,
|
||||
[TaskId] = @TaskId
|
||||
WHERE [Id] = @Id
|
||||
END
|
||||
|
@ -10,9 +10,11 @@ CREATE TABLE [dbo].[Notification]
|
||||
[Body] NVARCHAR (MAX) NULL,
|
||||
[CreationDate] DATETIME2 (7) NOT NULL,
|
||||
[RevisionDate] DATETIME2 (7) NOT NULL,
|
||||
[TaskId] UNIQUEIDENTIFIER NULL,
|
||||
CONSTRAINT [PK_Notification] PRIMARY KEY CLUSTERED ([Id] ASC),
|
||||
CONSTRAINT [FK_Notification_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]),
|
||||
CONSTRAINT [FK_Notification_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id])
|
||||
CONSTRAINT [FK_Notification_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id]),
|
||||
CONSTRAINT [FK_Notification_SecurityTask] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[SecurityTask] ([Id])
|
||||
);
|
||||
|
||||
|
||||
@ -30,3 +32,6 @@ GO
|
||||
CREATE NONCLUSTERED INDEX [IX_Notification_OrganizationId]
|
||||
ON [dbo].[Notification]([OrganizationId] ASC) WHERE OrganizationId IS NOT NULL;
|
||||
|
||||
GO
|
||||
CREATE NONCLUSTERED INDEX [IX_Notification_TaskId]
|
||||
ON [dbo].[Notification] ([TaskId] ASC) WHERE TaskId IS NOT NULL;
|
||||
|
Reference in New Issue
Block a user