|
@ -20,6 +20,9 @@ synopsis() { |
|
|
printf "\t restore <DB_NAME> <FILE> [--yes]\n" |
|
|
printf "\t restore <DB_NAME> <FILE> [--yes]\n" |
|
|
printf "\t ---------------------------\n" |
|
|
printf "\t ---------------------------\n" |
|
|
printf "\t rename <DB_NAME> <NEW_NAME>\n" |
|
|
printf "\t rename <DB_NAME> <NEW_NAME>\n" |
|
|
|
|
|
if [[ "$TARGET" != 'prod' ]]; then |
|
|
|
|
|
printf "\t drop <DB_NAME> # unless PROD!\n" |
|
|
|
|
|
fi |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
list() { |
|
|
list() { |
|
@ -134,11 +137,17 @@ rename() { |
|
|
console "psql -c \"ALTER DATABASE \\\"$DB_NAME\\\" RENAME TO \\\"$DB_NEW_NAME\\\" \"" |
|
|
console "psql -c \"ALTER DATABASE \\\"$DB_NAME\\\" RENAME TO \\\"$DB_NEW_NAME\\\" \"" |
|
|
console "psql -c \"ALTER USER \\\"$DB_NAME\\\" RENAME TO \\\"$DB_NEW_NAME\\\" \"" |
|
|
console "psql -c \"ALTER USER \\\"$DB_NAME\\\" RENAME TO \\\"$DB_NEW_NAME\\\" \"" |
|
|
console "psql -c \"ALTER USER \\\"$DB_NEW_NAME\\\" PASSWORD '$DB_NEW_NAME' \"" |
|
|
console "psql -c \"ALTER USER \\\"$DB_NEW_NAME\\\" PASSWORD '$DB_NEW_NAME' \"" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
drop() { |
|
|
|
|
|
console "dropdb $DB_NAME" |
|
|
|
|
|
console "dropuser $DB_NAME" |
|
|
|
|
|
echo "$DB_NAME dropped!" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# MAIN |
|
|
# MAIN |
|
|
. "$MIAOU_BASEDIR/lib/init.sh" |
|
|
. "$MIAOU_BASEDIR/lib/init.sh" |
|
|
|
|
|
TARGET=$(grep -Es "^target:" /etc/miaou/defaults.yaml | cut -d ' ' -f2) |
|
|
|
|
|
|
|
|
[[ $# -lt 1 ]] && synopsis && exit 1 |
|
|
[[ $# -lt 1 ]] && synopsis && exit 1 |
|
|
ACTION=$1 |
|
|
ACTION=$1 |
|
@ -193,6 +202,12 @@ rename) |
|
|
DB_NEW_NAME=$3 |
|
|
DB_NEW_NAME=$3 |
|
|
rename |
|
|
rename |
|
|
;; |
|
|
;; |
|
|
|
|
|
drop) |
|
|
|
|
|
[[ $# -lt 2 ]] && synopsis && exit 1 |
|
|
|
|
|
[[ "$TARGET" = 'prod' ]] && synopsis && exit 2 |
|
|
|
|
|
DB_NAME=$2 |
|
|
|
|
|
drop |
|
|
|
|
|
;; |
|
|
*) |
|
|
*) |
|
|
synopsis |
|
|
synopsis |
|
|
exit 1 |
|
|
exit 1 |
|
|