Connect to database before upgrading it

This change ensure we are connected to the database before
we upgrade it.

Change-Id: Ia0be33892a99897ff294d004f4d935f3753e6200