feat(CF-580): Add schema support and metadata tracking for session notes recovery
- Migration 025: Add 'abandoned' status to sessions CHECK constraint (fixes blocking issue) - Migration 026: Add recovery metadata columns (recovered_from, recovered_at) to track note recovery source - Update sessionRecoverOrphaned to recover notes from temp files when marking sessions abandoned - Update notes-parser to track recovery source and timestamp for analytics These changes complete Priority 3, 5 and part of Priority 1 for CF-572 Session Notes Loss fix. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
13
migrations/025_add_abandoned_status.sql
Normal file
13
migrations/025_add_abandoned_status.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
-- Migration 025: Add 'abandoned' status to sessions
|
||||
-- Purpose: Fix CF-572 schema constraint issue preventing orphan recovery
|
||||
-- Context: sessionRecoverOrphaned() tries to set status='abandoned' but constraint only allows 'active', 'completed', 'interrupted'
|
||||
|
||||
ALTER TABLE sessions
|
||||
DROP CONSTRAINT IF EXISTS sessions_status_check;
|
||||
|
||||
ALTER TABLE sessions
|
||||
ADD CONSTRAINT sessions_status_check
|
||||
CHECK (status IN ('active', 'completed', 'interrupted', 'abandoned'));
|
||||
|
||||
COMMENT ON CONSTRAINT sessions_status_check ON sessions
|
||||
IS 'Valid session statuses including abandoned for orphaned sessions (CF-572)';
|
||||
16
migrations/026_session_notes_recovery_metadata.sql
Normal file
16
migrations/026_session_notes_recovery_metadata.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
-- Migration 026: Add recovery metadata to session_notes
|
||||
-- Purpose: Track which notes were recovered vs normally saved for CF-572 analytics
|
||||
|
||||
ALTER TABLE session_notes
|
||||
ADD COLUMN IF NOT EXISTS recovered_from TEXT,
|
||||
ADD COLUMN IF NOT EXISTS recovered_at TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_session_notes_recovered
|
||||
ON session_notes(recovered_from)
|
||||
WHERE recovered_from IS NOT NULL;
|
||||
|
||||
COMMENT ON COLUMN session_notes.recovered_from
|
||||
IS 'Source of recovery: "recovered" (daemon/orphan), "manual" (MCP tool), NULL (normal save)';
|
||||
|
||||
COMMENT ON COLUMN session_notes.recovered_at
|
||||
IS 'Timestamp when note was recovered (NULL for normal saves)';
|
||||
Reference in New Issue
Block a user