ALTER TABLE download_clients ADD COLUMN IF NOT EXISTS url TEXT;
ALTER TABLE download_clients ADD COLUMN IF NOT EXISTS api_key TEXT;
ALTER TABLE download_clients ADD COLUMN IF NOT EXISTS category TEXT NOT NULL DEFAULT 'umm';
ALTER TABLE download_clients ADD COLUMN IF NOT EXISTS priority INTEGER NOT NULL DEFAULT 0;
ALTER TABLE download_clients ADD COLUMN IF NOT EXISTS protocol TEXT NOT NULL DEFAULT 'nzb';

UPDATE download_clients SET url = 'http://' || host || ':' || port::text WHERE url IS NULL;

ALTER TABLE download_clients ALTER COLUMN url SET NOT NULL;

ALTER TABLE download_clients DROP COLUMN IF EXISTS host;
ALTER TABLE download_clients DROP COLUMN IF EXISTS port;
ALTER TABLE download_clients DROP COLUMN IF EXISTS username;
ALTER TABLE download_clients DROP COLUMN IF EXISTS password;
