migrate_create 720 B

1234567891011121314151617181920212223242526
  1. #!/bin/bash
  2. if [ "$1" == "" ]; then
  3. echo "Error: migrate name must be specified as first arg"
  4. exit 1
  5. else
  6. # Code path
  7. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  8. if hash realpath 2>/dev/null; then
  9. export CODEBASE=$(realpath $SCRIPT_DIR/..)
  10. elif hash grealpath 2>/dev/null; then
  11. export CODEBASE=$(grealpath $SCRIPT_DIR/..)
  12. else
  13. export CODEBASE=$(readlink -e $SCRIPT_DIR/..)
  14. fi
  15. if [ -z "$CODEBASE" ]; then
  16. echo "Unable to determine absolute codebase directory"
  17. exit 1
  18. fi
  19. cd "$CODEBASE"
  20. sudo /usr/local/bin/docker-compose run --rm --no-deps app node node_modules/knex/bin/cli.js migrate:make "$1"
  21. exit $?
  22. fi