DO $$
BEGIN

    IF NOT EXISTS (
        SELECT 1
        FROM information_schema.columns
        WHERE table_name = 't_hschet_zap'
        AND column_name = 'soc2'
    ) THEN
        ALTER TABLE AKUZ.T_HSCHET_ZAP RENAME COLUMN SOC TO SOC2;
    END IF;

    IF NOT EXISTS (
        SELECT 1
        FROM information_schema.columns
        WHERE table_name = 't_schet_zap'
        AND column_name = 'soc2'
    ) THEN
        ALTER TABLE AKUZ.T_SCHET_ZAP RENAME COLUMN SOC TO SOC2;
    END IF;

END $$;

ALTER TABLE AKUZ.T_HSCHET_ZAP ADD IF NOT EXISTS "soc" varchar(3) NULL;

ALTER TABLE AKUZ.T_SCHET_ZAP ADD IF NOT EXISTS "soc" varchar(3) NULL;