Skip to main content

## MIGRATION_004

# Constant MIGRATION_004

Source

    const MIGRATION_004: &str = r#"
    -- Add priority column for queue ordering
    ALTER TABLE downloads ADD COLUMN priority INTEGER DEFAULT 0;

    -- Add bytes_downloaded for resume support
    ALTER TABLE downloads ADD COLUMN bytes_downloaded INTEGER DEFAULT 0;

    -- Create index for efficient queue processing (priority DESC, FIFO within same priority)
    CREATE INDEX IF NOT EXISTS idx_downloads_queue
      ON downloads(status, priority DESC, queued_at ASC)
      WHERE status IN ('pending', 'downloading');
    "#;

Expand description

Migration to enhance downloads table with priority and bytes_downloaded