Lewis Hamilton will join Ferrari next season with major consequences for Mercedes.