-- CreateTable
CREATE TABLE `Notification` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `title` VARCHAR(191) NOT NULL,
    `message` VARCHAR(191) NOT NULL,
    `type` ENUM('GENERAL', 'BOOKING', 'PAYMENT', 'ALERT', 'PROMOTION', 'SYSTEM') NOT NULL DEFAULT 'GENERAL',
    `status` ENUM('PENDING', 'SENT', 'READ') NOT NULL DEFAULT 'PENDING',
    `image` VARCHAR(191) NULL,
    `data` JSON NULL,
    `sentAt` DATETIME(3) NULL,
    `readAt` DATETIME(3) NULL,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `senderAdminId` INTEGER NULL,
    `senderStaffId` INTEGER NULL,
    `receiverAdminId` INTEGER NULL,
    `receiverStaffId` INTEGER NULL,
    `receiverCustId` INTEGER NULL,
    `parlourId` INTEGER NULL,
    `staffId` INTEGER NULL,
    `customerId` INTEGER NULL,

    INDEX `Notification_receiverAdminId_idx`(`receiverAdminId`),
    INDEX `Notification_receiverStaffId_idx`(`receiverStaffId`),
    INDEX `Notification_receiverCustId_idx`(`receiverCustId`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `Notification` ADD CONSTRAINT `Notification_senderAdminId_fkey` FOREIGN KEY (`senderAdminId`) REFERENCES `Admin`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Notification` ADD CONSTRAINT `Notification_senderStaffId_fkey` FOREIGN KEY (`senderStaffId`) REFERENCES `Staff`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Notification` ADD CONSTRAINT `Notification_receiverAdminId_fkey` FOREIGN KEY (`receiverAdminId`) REFERENCES `Admin`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Notification` ADD CONSTRAINT `Notification_receiverStaffId_fkey` FOREIGN KEY (`receiverStaffId`) REFERENCES `Staff`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Notification` ADD CONSTRAINT `Notification_receiverCustId_fkey` FOREIGN KEY (`receiverCustId`) REFERENCES `Customer`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Notification` ADD CONSTRAINT `Notification_parlourId_fkey` FOREIGN KEY (`parlourId`) REFERENCES `Parlour`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Notification` ADD CONSTRAINT `Notification_staffId_fkey` FOREIGN KEY (`staffId`) REFERENCES `Staff`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Notification` ADD CONSTRAINT `Notification_customerId_fkey` FOREIGN KEY (`customerId`) REFERENCES `Customer`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
