Upgrading mattermost versions

What is the procedure that we need to follow if I want to upgrade mattermost version hosted in Elastic Beanstalk?
I have read the upgrade documentation, after reading the document I had a doubt, what happens to the data stored in the database while upgrading? Generally in two cases:

  1. upgrading from team-edition to enterprise edition.
  2. upgrading from old version to new version in same edition.

Also I need help installing mattermost in Elastic Beanstalk for production.