mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-18 23:42:59 +00:00
make db scripts accept one db at a time
This commit is contained in:
@@ -1,14 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
# initialize jupyterhub databases for testing
|
||||
|
||||
set -e
|
||||
|
||||
MYSQL="mysql --user root -e "
|
||||
PSQL="psql --user postgres -c "
|
||||
|
||||
case "$DB" in
|
||||
"mysql")
|
||||
EXTRA_CREATE='CHARACTER SET utf8 COLLATE utf8_general_ci'
|
||||
SQL="$MYSQL"
|
||||
;;
|
||||
"postgres")
|
||||
SQL="$PSQL"
|
||||
;;
|
||||
*)
|
||||
echo '$DB must be mysql or postgres'
|
||||
exit 1
|
||||
esac
|
||||
|
||||
set -x
|
||||
|
||||
# drop databases if they don't exist
|
||||
$MYSQL 'DROP DATABASE jupyterhub_upgrade' 2>/dev/null || true
|
||||
$PSQL 'DROP DATABASE jupyterhub_upgrade' 2>/dev/null || true
|
||||
|
||||
# create the databases
|
||||
$MYSQL 'CREATE DATABASE jupyterhub_upgrade CHARACTER SET utf8 COLLATE utf8_general_ci;'
|
||||
$PSQL 'CREATE DATABASE jupyterhub_upgrade;'
|
||||
$SQL 'DROP DATABASE jupyterhub;' 2>/dev/null || true
|
||||
$SQL "CREATE DATABASE jupyterhub ${EXTRA_CREATE};"
|
||||
$SQL 'DROP DATABASE jupyterhub_upgrade;' 2>/dev/null || true
|
||||
$SQL "CREATE DATABASE jupyterhub_upgrade ${EXTRA_CREATE};"
|
||||
|
Reference in New Issue
Block a user