
ALTER TABLE th_sessions ADD COLUMN IF NOT EXISTS tags JSONB;
ALTER TABLE th_sessions ADD COLUMN IF NOT EXISTS category VARCHAR(50);
ALTER TABLE th_sessions ADD COLUMN IF NOT EXISTS read_status INTEGER DEFAULT 1;


-- Add comments to document the fields
COMMENT ON COLUMN th_sessions.tags IS 'Task-level tags generated by AI, stored as JSON array';
COMMENT ON COLUMN th_sessions.category IS 'File category: food, report, medicine, rtc, journal, other';

-- Create indexes for search
CREATE INDEX IF NOT EXISTS idx_th_sessions_tags ON th_sessions USING GIN (tags);
CREATE INDEX IF NOT EXISTS idx_th_sessions_category ON th_sessions(category);
