How to properly migrate a dashboard

Hi everyone! I upgraded Grafana to 9.4 from 8.4 and my dashboard didn’t work anymore. I exported 8.4 dashboard json and created a new dashboard from it in 9.4, got the error:

Failed to upgrade legacy queries Datasource was not found

I created a dummy new 9.4 dashboard with a simple query, got a new datasource uid and updated 8.4 dashboard json with it - it worked! But I love to think there is a better way to do it, so dashboard can be migrated seamlessly without editing json?
It also makes me thinking what actually datasource uid means? I thought it was just a unique ID for a particular datasource, however it looks like it is rather a datasource type? For example, if my datasource is Amazon Timestream, will its uid always be the same within the same Grafana version?