Last active
August 29, 2015 14:05
-
-
Save davidoram/62c2696224980609ede9 to your computer and use it in GitHub Desktop.
Generate schemaspy docs for postgres db
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Spit out Schemaspy docs for a rails project, on a postgres db | |
# | |
# Assumes: | |
# - Have installed graphviz installed & in the path | |
# If not run 'brew install graphviz' | |
# - java installed & in the path | |
# - postgresql-9.3-1102.jdbc41.jar in current dir | |
# - schemaSpy_5.0.0.jar in current dir | |
# See http://www.craigkerstiens.com/2013/07/29/documenting-your-postgres-database/ for instructions on adding comments | |
# TODO Why this not working - java returning non-zero! | |
#set -e | |
usage() | |
{ | |
cat << EOF | |
usage: $0 options | |
This script imports Airpoints data from a csv file into Spree | |
OPTIONS: | |
-d Database eg: 'mrr_development'. Will output to a new directory of the same name | |
EOF | |
} | |
DATABASE= | |
while getopts “hd:” OPTION | |
do | |
case $OPTION in | |
h) | |
usage | |
exit 1 | |
;; | |
d) | |
DATABASE=$OPTARG | |
;; | |
?) | |
usage | |
exit | |
;; | |
esac | |
done | |
if [[ -z $DATABASE ]] | |
then | |
usage | |
exit 1 | |
fi | |
java -jar schemaSpy_5.0.0.jar -dp ./postgresql-9.3-1102.jdbc41.jar -t pgsql -db ${DATABASE} -u ${USER} -host localhost -o ${DATABASE} -all -rails -hq | |
echo "Opening '$DATABASE/index.html' in browser..." | |
open -a Safari $DATABASE/index.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment