fork 0k-charms
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
893 B

  1. #!/bin/bash
  2. . lib/common
  3. set -e
  4. DBNAME="$(relation-get dbname)" || exit 1
  5. initing="${GOGOCARTO_CODE}"/.initing-${DBNAME}
  6. if [ -e "$initing" ]; then
  7. exit 0
  8. fi
  9. inited="${GOGOCARTO_CODE}"/.inited-${DBNAME}
  10. MONGO_URL=mongodb://${TARGET_SERVICE_NAME}:27017
  11. cat <<EOF >> ${GOGOCARTO_CODE}/.env
  12. ###> doctrine/mongodb-odm-bundle ###
  13. MONGODB_URL=$MONGO_URL
  14. MONGODB_DATABASE=$DBNAME
  15. ###< doctrine/mongodb-odm-bundle ###
  16. DATABASE_NAME=$DBNAME
  17. EOF
  18. if [ -e "$inited" ]; then
  19. exit 0
  20. fi
  21. ## came from ``Makefile`` in git's gogocarto source code. Target load-fixtures.
  22. touch "$initing"
  23. trap_add EXIT,ERR "rm -v \"$initing\""
  24. symphony doctrine:mongodb:schema:create &&
  25. symphony doctrine:mongodb:generate:hydrators &&
  26. symphony doctrine:mongodb:generate:proxies &&
  27. symphony doctrine:mongodb:fixtures:load -n || {
  28. err "Mongo database initialization failed."
  29. exit 1
  30. }
  31. touch "$inited"