BEGIN;

ALTER TABLE sonex.products
    ALTER COLUMN online_only DROP DEFAULT;

ALTER TABLE sonex.products
    ALTER COLUMN online_only TYPE boolean
    USING CASE
        WHEN online_only IS NULL THEN false
        WHEN lower(trim(online_only::text)) IN ('ja', 'true', 't', '1', 'yes', 'y') THEN true
        ELSE false
    END;

ALTER TABLE sonex.products
    ALTER COLUMN online_only SET DEFAULT false,
    ALTER COLUMN online_only SET NOT NULL;

COMMIT;
