CREATE TABLE IF NOT EXISTS `user_notifications` (
  `id` VARCHAR(100) PRIMARY KEY,
  `user_id` VARCHAR(100) NOT NULL,
  `title` VARCHAR(255) NOT NULL,
  `body` TEXT NOT NULL,
  `notification_type` VARCHAR(50) DEFAULT 'general',
  `image_url` VARCHAR(500) DEFAULT NULL,
  `data_payload` JSON DEFAULT NULL,
  `is_read` BOOLEAN DEFAULT false,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (`user_id`) REFERENCES `users`(`user_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE INDEX idx_notifications_user ON user_notifications(user_id, created_at DESC);
