ALTER TABLE radios
    ADD COLUMN IF NOT EXISTS direct_login varchar(120) NULL AFTER stream_mount,
    ADD COLUMN IF NOT EXISTS direct_password varchar(255) NULL AFTER direct_login,
    ADD COLUMN IF NOT EXISTS direct_server varchar(190) NULL AFTER direct_password,
    ADD COLUMN IF NOT EXISTS direct_port int NULL AFTER direct_server,
    ADD COLUMN IF NOT EXISTS direct_mountpoint varchar(190) NULL AFTER direct_port,
    ADD COLUMN IF NOT EXISTS direct_stream_url varchar(255) NULL AFTER direct_mountpoint,
    ADD COLUMN IF NOT EXISTS direct_url varchar(255) NULL AFTER direct_stream_url,
    ADD COLUMN IF NOT EXISTS direct_password_updated_at datetime NULL AFTER direct_url,
    ADD COLUMN IF NOT EXISTS last_stream_restart_at datetime NULL AFTER direct_password_updated_at;

UPDATE radios
SET
    direct_login = COALESCE(NULLIF(direct_login, ''), 'source'),
    direct_password_updated_at = COALESCE(direct_password_updated_at, NOW())
WHERE direct_login IS NULL
   OR direct_login = '';
