ALTER TABLE media_categories
    ADD COLUMN IF NOT EXISTS scope enum('user','radio') NOT NULL DEFAULT 'radio' AFTER radio_id,
    MODIFY radio_id int(11) NULL;

ALTER TABLE media_files
    ADD COLUMN IF NOT EXISTS scope enum('user','radio') NOT NULL DEFAULT 'radio' AFTER radio_id,
    MODIFY radio_id int(11) NULL;

CREATE INDEX IF NOT EXISTS idx_media_categories_scope ON media_categories (user_id, scope, radio_id, content_type);
CREATE INDEX IF NOT EXISTS idx_media_files_scope ON media_files (user_id, scope, radio_id, content_type);

UPDATE media_categories
SET scope = 'user', radio_id = NULL
WHERE content_type = 'music';

UPDATE media_files
SET scope = 'user', radio_id = NULL
WHERE content_type = 'music';
