The main Bubble source repository. Contains the Bubble API server, the web UI, documentation and utilities. https://getbubblenow.com
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

54 rader
1.7 KiB

  1. #!/bin/bash
  2. #
  3. # Drop the various temporary databases that sometimes get left around by the tests
  4. # Do not run this command while tests are running
  5. #
  6. # Usage:
  7. #
  8. # cleanup_bubble_databases [db-match] [fg]
  9. #
  10. # db-match all databases that contain this string will be dropped. default is "bubble_"
  11. # foreground normally a forked shell is used for each "dropdb" command; if the last argument is "fg" then we'll use the current shell
  12. #
  13. # Note: if you specify db-match "bubble", this would normally include the default bubble database, but it will be
  14. # specifically excluded by this script, to avoid dropping a real database with real data in it.
  15. #
  16. # To drop the "bubble" database, you must drop it directly with dropdb.
  17. #
  18. SCRIPT="${0}"
  19. SCRIPT_DIR=$(cd $(dirname ${SCRIPT}) && pwd)
  20. DB_MATCH="${1:-bubble_}"
  21. DB_USER="$(whoami)"
  22. FORK_DROP=1
  23. if [[ "${2:-fork}" = "fg" ]] ; then
  24. FORK_DROP=0
  25. fi
  26. if [[ ${FORK_DROP} -eq 1 ]] ; then
  27. set -m
  28. fi
  29. DATABASE_COUNT="$(echo "select datname from pg_database" | psql -qt -U ${DB_USER} template1 | grep ${DB_MATCH} | wc -l | tr -d ' ')"
  30. if [[ ${DATABASE_COUNT} -gt 0 ]] ; then
  31. echo "Cleaning up ${DATABASE_COUNT} databases..."
  32. DATABASES="$(echo "select datname from pg_database" | psql -qt -U ${DB_USER} template1 | grep ${DB_MATCH} | tr -d ' ')"
  33. if [[ ! -z "${DATABASES}" ]] ; then
  34. for db in ${DATABASES} ; do
  35. if [[ "${db}" == "bubble" ]] ; then
  36. echo "Not dropping bubble default database"
  37. else
  38. if [[ "${FORK_DROP}" -eq 1 ]] ; then
  39. dropdb -U ${DB_USER} ${db} &
  40. else
  41. dropdb -U ${DB_USER} ${db} || echo "Error dropping database: ${db}"
  42. fi
  43. fi
  44. done
  45. fi
  46. else
  47. echo "No databases whose name contains \"${DB_MATCH}\" to clean up"
  48. fi