2
0

drop_database.sh 570 B

1234567891011121314
  1. #!/bin/sh
  2. # Drop and re-create a local NetBox database, granting the role named after
  3. # it create on the database and on schema public. The schema grant is
  4. # required since PostgreSQL 15. Runs psql as the postgres superuser via sudo.
  5. #
  6. # Usage: scripts/drop_database.sh [database=netbox]
  7. # Example: scripts/drop_database.sh
  8. DB=${1:-netbox}
  9. sudo -u postgres psql -c "drop database $DB"
  10. sudo -u postgres psql -c "create database $DB"
  11. sudo -u postgres psql -c "grant create on database $DB to $DB"
  12. sudo -u postgres psql -d $DB -c "grant create on schema public to $DB"