20 lines
788 B
MySQL
20 lines
788 B
MySQL
|
|
-- Create user_notifications table for in-app notifications
|
||
|
|
CREATE TABLE IF NOT EXISTS `user_notifications` (
|
||
|
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||
|
|
`user_id` INT NOT NULL,
|
||
|
|
`type` VARCHAR(50) NOT NULL,
|
||
|
|
`title` VARCHAR(255) NOT NULL,
|
||
|
|
`message` TEXT NOT NULL,
|
||
|
|
`domain_id` INT NULL,
|
||
|
|
`is_read` BOOLEAN DEFAULT FALSE,
|
||
|
|
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||
|
|
`read_at` TIMESTAMP NULL,
|
||
|
|
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
|
||
|
|
FOREIGN KEY (`domain_id`) REFERENCES `domains`(`id`) ON DELETE SET NULL,
|
||
|
|
INDEX `idx_user_id` (`user_id`),
|
||
|
|
INDEX `idx_is_read` (`is_read`),
|
||
|
|
INDEX `idx_created_at` (`created_at`),
|
||
|
|
INDEX `idx_type` (`type`)
|
||
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||
|
|
|