ensure auth and select db happen before anything else