do $$
declare
    _list refcursor;
    _item record;
begin
    open _list for
        select *
        from pg_tables
        where
            pg_tables.schemaname = 'public'
        order by pg_tables.tablename;
            
    fetch _list into _item;
    
    while found loop
    
        begin
            if exists (
                select 1
                from pg_attribute
                where attrelid = cast('public.' || _item.tablename as regclass) and
                      attname = 'id_sinc' and
                      not attisdropped) then
                      
                execute 'alter table ' || _item.tablename || ' drop column ' || quote_ident('id_sinc');
            end if;
        
            if exists (
                select 1
                from pg_attribute
                where attrelid = cast('public.' || _item.tablename as regclass) and
                      attname = 'id_est_sinc' and
                      not attisdropped) then
                      
                execute 'alter table ' || _item.tablename || ' drop column ' || quote_ident('id_est_sinc');
            end if;
            
        exception when others then
            raise notice '% %', SQLERRM, SQLSTATE;
        end;
        
        fetch _list into _item;
    end loop; 
end
$$;