ALTER TABLE resource_policies
    ADD COLUMN IF NOT EXISTS file_transfer_mode TEXT NOT NULL DEFAULT 'disabled';

UPDATE resource_policies
SET file_transfer_mode = 'disabled',
    file_transfer_enabled = FALSE
WHERE file_transfer_mode IS NULL
   OR file_transfer_mode = ''
   OR file_transfer_mode = 'disabled';

ALTER TABLE resource_policies
    DROP CONSTRAINT IF EXISTS resource_policies_file_transfer_mode_check;

ALTER TABLE resource_policies
    ADD CONSTRAINT resource_policies_file_transfer_mode_check
    CHECK (file_transfer_mode IN ('disabled', 'client_to_server', 'server_to_client', 'bidirectional'));
