-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PM-14590] Modify Notification database table #5361
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d80dc66
Added notification type enum
gbubemismith e1763e5
created migration files
gbubemismith 7a5a031
made sprocs backward compatible
gbubemismith 09bed90
made sprocs backward compatible
gbubemismith 70ec875
Fixed linting
gbubemismith b57ed8a
Altered table to require an optional taskId
gbubemismith f1d8071
formatted code
gbubemismith 052b2cf
Added foreignkey
gbubemismith 679286f
Formatted code
gbubemismith 6ff61df
fixed order
gbubemismith File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/Infrastructure.EntityFramework/NotificationCenter/Models/Notification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
util/Migrator/DbScripts/2025-02-07_00_AddOptionalNotificationTaskId.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
-- Add optional TaskId column to Notification table | ||
IF COL_LENGTH('[dbo].[Notification]', 'TaskId') IS NULL | ||
BEGIN | ||
ALTER TABLE [dbo].[Notification] | ||
ADD [TaskId] UNIQUEIDENTIFIER NULL | ||
|
||
ALTER TABLE [dbo].[Notification] | ||
ADD CONSTRAINT [FK_Notification_SecurityTask] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[SecurityTask] ([Id]) | ||
END | ||
GO | ||
|
||
IF NOT EXISTS (SELECT * | ||
FROM sys.indexes | ||
WHERE name = 'IX_Notification_TaskId') | ||
BEGIN | ||
CREATE NONCLUSTERED INDEX [IX_Notification_TaskId] | ||
ON [dbo].[Notification] ([TaskId] ASC) WHERE TaskId IS NOT NULL; | ||
END | ||
GO | ||
|
||
-- Alter Notification_Create and Notification_Update stored procedures to include TaskId | ||
CREATE OR ALTER PROCEDURE [dbo].[Notification_Create] | ||
@Id UNIQUEIDENTIFIER OUTPUT, | ||
@Priority TINYINT, | ||
@Global BIT, | ||
@ClientType TINYINT, | ||
@UserId UNIQUEIDENTIFIER, | ||
@OrganizationId UNIQUEIDENTIFIER, | ||
@Title NVARCHAR(256), | ||
@Body NVARCHAR(MAX), | ||
@CreationDate DATETIME2(7), | ||
@RevisionDate DATETIME2(7), | ||
@TaskId UNIQUEIDENTIFIER = NULL | ||
AS | ||
BEGIN | ||
SET NOCOUNT ON | ||
|
||
INSERT INTO [dbo].[Notification] ( | ||
[Id], | ||
[Priority], | ||
[Global], | ||
[ClientType], | ||
[UserId], | ||
[OrganizationId], | ||
[Title], | ||
[Body], | ||
[CreationDate], | ||
[RevisionDate], | ||
[TaskId] | ||
) | ||
VALUES ( | ||
@Id, | ||
@Priority, | ||
@Global, | ||
@ClientType, | ||
@UserId, | ||
@OrganizationId, | ||
@Title, | ||
@Body, | ||
@CreationDate, | ||
@RevisionDate, | ||
@TaskId | ||
) | ||
END | ||
GO | ||
|
||
CREATE OR ALTER PROCEDURE [dbo].[Notification_Update] | ||
@Id UNIQUEIDENTIFIER, | ||
@Priority TINYINT, | ||
@Global BIT, | ||
@ClientType TINYINT, | ||
@UserId UNIQUEIDENTIFIER, | ||
@OrganizationId UNIQUEIDENTIFIER, | ||
@Title NVARCHAR(256), | ||
@Body NVARCHAR(MAX), | ||
@CreationDate DATETIME2(7), | ||
@RevisionDate DATETIME2(7), | ||
@TaskId UNIQUEIDENTIFIER = NULL | ||
AS | ||
BEGIN | ||
SET NOCOUNT ON | ||
|
||
UPDATE [dbo].[Notification] | ||
SET [Priority] = @Priority, | ||
[Global] = @Global, | ||
[ClientType] = @ClientType, | ||
[UserId] = @UserId, | ||
[OrganizationId] = @OrganizationId, | ||
[Title] = @Title, | ||
[Body] = @Body, | ||
[CreationDate] = @CreationDate, | ||
[RevisionDate] = @RevisionDate, | ||
[TaskId] = @TaskId | ||
WHERE [Id] = @Id | ||
END | ||
GO | ||
|
||
-- Recreate NotificationView | ||
CREATE OR ALTER VIEW [dbo].[NotificationView] | ||
AS | ||
SELECT | ||
* | ||
FROM | ||
[dbo].[Notification] | ||
GO | ||
|
||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
โ๏ธ I like these to be in order too.