Can I migrate and upgrade NextCloud - simultaneously?

Current Scenario and Problem:
I am migrating NextCloud to new virtual servers. Currently, I am using NextCloud v14 and the latest available version is v17.

Question:

  1. I was not clear if I can migrate NextCloud to a new server by directly installing the latest version of NextCloud on the new server and migrating? Will that create problems while migrating database between two different versions of NextCloud? OR
  2. Do I need to first upgrade the NextCloud to the latest version on my current server and then migrate to a new server with the same version of NextCloud?

Any useful links, responses and experiences would be much appreciated. Thank you in advance.

By default it is not possible to skip any major version, so my recommendation would be to update the existing server to Nextcloud 18 (!!) first and then to export the database and move the data to the new server where you import it again. You should find further information how to migrate to a new version using the search function of this forum.