2018-10-03 08:37:34 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Provide me with a postgres database name, and I will:
|
|
|
|
# - Drop the database
|
|
|
|
# - Recreate the database
|
|
|
|
# - Run the vulcanizedb migration
|
|
|
|
|
|
|
|
if [ "$1" = "" ]; then
|
|
|
|
echo "Provide a database name to reset"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
db=$1
|
|
|
|
dir=$(basename "$(pwd)")
|
2020-08-31 15:52:47 +00:00
|
|
|
if [ $dir != "ipld-eth-server" ]
|
2018-10-03 08:37:34 +00:00
|
|
|
then
|
2020-08-31 15:52:47 +00:00
|
|
|
echo "Run me from the ipld-eth-server root dir"
|
2018-10-03 08:37:34 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
user=$(whoami)
|
|
|
|
psql -c "DROP DATABASE $db" postgres
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
psql -c "CREATE DATABASE $db WITH OWNER $user" postgres
|
|
|
|
make migrate HOST_NAME=localhost NAME=$db PORT=5432
|
|
|
|
else
|
|
|
|
echo "Couldnt drop the database. Are you connected? Does it exist?"
|
|
|
|
fi
|