﻿START TRANSACTION;
CREATE TABLE `UserNotifications` (
    `Id` char(36) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,
    `OwnerUserId` varchar(255) NOT NULL,
    `OperationId` char(36) CHARACTER SET ascii COLLATE ascii_general_ci NULL,
    `Kind` varchar(64) NOT NULL,
    `Title` varchar(160) NOT NULL,
    `Message` varchar(512) NOT NULL,
    `LinkPath` varchar(256) NULL,
    `CreatedAtUtc` datetime(6) NOT NULL,
    `ReadAtUtc` datetime(6) NULL,
    `DismissedAtUtc` datetime(6) NULL,
    CONSTRAINT `PK_UserNotifications` PRIMARY KEY (`Id`),
    CONSTRAINT `FK_UserNotifications_UserOperations_OperationId`
        FOREIGN KEY (`OperationId`) REFERENCES `UserOperations` (`Id`) ON DELETE SET NULL
) CHARACTER SET=utf8mb4;

CREATE UNIQUE INDEX `IX_UserNotifications_OperationId` ON `UserNotifications` (`OperationId`);

CREATE INDEX `IX_UserNotifications_OwnerUserId_DismissedAtUtc_ReadAtUtc_Create` ON `UserNotifications` (`OwnerUserId`, `DismissedAtUtc`, `ReadAtUtc`, `CreatedAtUtc`);

INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`)
VALUES ('20260802225941_AddUserNotifications', '9.0.14');

COMMIT;

