migration: Share postgres dsn resolution code
Created by: efritz
Move the postgres DSN resolution done by the frontend into shared database code (may be refactored/reorganized later) so that it can later be used by the migrator instance as well.
(It will need to have the same envvars as the frontend as it won't be guaranteed to be able to connect to a working frontend to get the service connection values during normal installation/upgrade flow)