File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ case "$1" in
122
122
$PLUGIN_COMMAND_PREFIX :create <name>, Create a $PLUGIN_SERVICE service
123
123
$PLUGIN_COMMAND_PREFIX :create-database <name> <db>, Create a $PLUGIN_SERVICE database in the specified service
124
124
$PLUGIN_COMMAND_PREFIX :destroy <name>, Delete the $PLUGIN_SERVICE service and stop its container if there are no links left
125
- $PLUGIN_COMMAND_PREFIX :destroy-database <name> <db>, Delete a $PLUGIN_SERVICE database on the specified service
125
+ $PLUGIN_COMMAND_PREFIX :destroy-database <name> <db>, Delete a $PLUGIN_SERVICE database in the specified service
126
126
$PLUGIN_COMMAND_PREFIX :export <name>, Export a dump of the $PLUGIN_SERVICE service database
127
127
$PLUGIN_COMMAND_PREFIX :expose <name> [port], Expose a $PLUGIN_SERVICE service on custom port if provided (random port otherwise)
128
128
$PLUGIN_COMMAND_PREFIX :import <name> < <file>, Import a dump into the $PLUGIN_SERVICE service database
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ source " $( dirname " $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) " ) /config"
3
+ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
4
+ source " $PLUGIN_BASE_PATH /common/functions"
5
+ source " $( dirname " $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) " ) /functions"
6
+
7
+ postgres-destroy-database-cmd () {
8
+ declare desc=" delete a $PLUGIN_SERVICE database from the specified service"
9
+ local cmd=" $PLUGIN_COMMAND_PREFIX :destroy-database" argv=(" $@ " ); [[ ${argv[0]} == " $cmd " ]] && shift 1
10
+ declare SERVICE=" $1 " DATABASE=" $2 "
11
+
12
+ [[ -z " $SERVICE " ]] && dokku_log_fail " Please specify a name for the service"
13
+ [[ -z " $DATABASE " ]] && dokku_log_fail " Please specify a name for the database"
14
+ verify_service_name " $SERVICE "
15
+ verify_database_name " $SERVICE " " $DATABASE "
16
+ SERVICE_ROOT=" $PLUGIN_DATA_ROOT /$SERVICE "
17
+ SERVICE_NAME=" $( get_service_name " $SERVICE " ) "
18
+
19
+ dokku_log_info1 " Deleting $DATABASE from $SERVICE "
20
+ if docker exec " $SERVICE_NAME " su - postgres -c " psql -c \" DROP DATABASE $DATABASE ;\" " 2> /dev/null && docker exec " $SERVICE_NAME " su - postgres -c " psql -c \" DROP USER $DATABASE ;\" " 2> /dev/null; then
21
+ rm -f " $SERVICE_ROOT /databases/$DATABASE "
22
+ rm -f " $SERVICE_ROOT /auth/$DATABASE "
23
+ dokku_log_info2 " $PLUGIN_SERVICE $SERVICE database deleted: $DATABASE "
24
+ else
25
+ dokku_log_fail " Could not delete the database"
26
+ fi
27
+ }
28
+
29
+ postgres-destroy-database-cmd " $@ "
You can’t perform that action at this time.
0 commit comments