Fix api build rake tasks for new installation

The order of rake tasks was wrong in the `api' role's build_api.sh.
Tasks that required the existence of the database were being run
before the database was being created in a brand-new installation.