The main Bubble source repository. Contains the Bubble API server, the web UI, documentation and utilities. https://getbubblenow.com
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

56 rindas
1.9 KiB

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