-- Migration: Unify note_layouts fields and remove is_read from note_comments
-- This migration:
-- 1. Removes the is_read column from note_comments table
-- 2. Removes lastCommentViewedAt and lastPriorityViewedAt columns from note_layouts table
-- 3. Adds the unified lastViewedAt column to note_layouts table

-- Step 1: Remove is_read from note_comments
ALTER TABLE `note_comments` DROP COLUMN `is_read`;

-- Step 2: Drop old columns from note_layouts
ALTER TABLE `note_layouts` DROP COLUMN `last_comment_viewed_at`;
ALTER TABLE `note_layouts` DROP COLUMN `last_priority_viewed_at`;

-- Step 3: Add unified lastViewedAt column to note_layouts
ALTER TABLE `note_layouts` ADD COLUMN `last_viewed_at` TIMESTAMP NULL DEFAULT NULL AFTER `reminder_at`;
