Skip to main content

## MIGRATION_010

# Constant MIGRATION_010

Source

    const MIGRATION_010: &str = r#"
    -- Add playback context tracking to user_data
    -- Tracks whether user played a container (album/playlist) or single item
    ALTER TABLE user_data ADD COLUMN playback_context_type TEXT;
    ALTER TABLE user_data ADD COLUMN playback_context_id TEXT;

    -- Index for efficient recently played queries
    CREATE INDEX IF NOT EXISTS idx_user_data_last_played
      ON user_data(user_id, last_played_at DESC)
      WHERE last_played_at IS NOT NULL;
    "#;

Expand description

Migration to add playback context tracking

- Adds playback_context_type column to track if user played a container or single item
- Adds playback_context_id column to store the container ID (album/playlist)
- Adds index for efficient recently played queries