﻿BEGIN TRANSACTION;
CREATE TABLE "UserNotifications" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_UserNotifications" PRIMARY KEY,
    "OwnerUserId" TEXT NOT NULL,
    "OperationId" TEXT NULL,
    "Kind" TEXT NOT NULL,
    "Title" TEXT NOT NULL,
    "Message" TEXT NOT NULL,
    "LinkPath" TEXT NULL,
    "CreatedAtUtc" TEXT NOT NULL,
    "ReadAtUtc" TEXT NULL,
    "DismissedAtUtc" TEXT NULL,
    CONSTRAINT "FK_UserNotifications_UserOperations_OperationId" FOREIGN KEY ("OperationId") REFERENCES "UserOperations" ("Id") ON DELETE SET NULL
);

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

CREATE INDEX "IX_UserNotifications_OwnerUserId_DismissedAtUtc_ReadAtUtc_CreatedAtUtc" ON "UserNotifications" ("OwnerUserId", "DismissedAtUtc", "ReadAtUtc", "CreatedAtUtc");

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

COMMIT;

