-- P5-4884 save house number and house extension in address field

BEGIN;
    UPDATE addresses SET address1 = TRIM(TRAILING FROM address1) || ' ' || TRIM(BOTH FROM house_number) WHERE house_number ~ '^[0-9\.]+$';

    UPDATE addresses SET address1 = address1 || ' ' || TRIM(BOTH FROM house_extension) WHERE house_extension IS NOT NULL;

    ALTER TABLE addresses DROP COLUMN house_number;

    ALTER TABLE addresses DROP COLUMN house_extension;

    ALTER TABLE contract_customers DROP COLUMN house_number;

COMMIT;
