From 5a923e54642c552af77f898c2b02e74cdba48d8f Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 2 Nov 2020 22:25:30 +0800 Subject: [PATCH] add goose script --- scripts/goose | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 scripts/goose diff --git a/scripts/goose b/scripts/goose new file mode 100755 index 000000000..bc293d1a8 --- /dev/null +++ b/scripts/goose @@ -0,0 +1,33 @@ +#!/bin/bash +set -e +export GOOSE_DRIVER=mysql + +if [[ -n $MYSQL_URL ]] ; then + export GOOSE_DBSTRING="$MYSQL_URL" +else + GOOSE_DBSTRING= + if [[ -n $MYSQL_USERNAME ]] ; then + GOOSE_DBSTRING="$MYSQL_USERNAME" + if [[ -n $MYSQL_PASSWORD ]] ; then + GOOSE_DBSTRING="$MYSQL_USERNAME:$MYSQL_PASSWORD" + fi + fi + if [[ -n $MYSQL_HOST ]] ; then + if [[ -n $MYSQL_PORT ]] ; then + GOOSE_DBSTRING="$GOOSE_DBSTRING@tcp($MYSQL_HOST:$MYSQL_PORT)" + else + GOOSE_DBSTRING="$GOOSE_DBSTRING@tcp($MYSQL_HOST)" + fi + else + if [[ -n $MYSQL_PORT ]] ; then + GOOSE_DBSTRING="$GOOSE_DBSTRING@tcp(localhost:$MYSQL_PORT)" + else + GOOSE_DBSTRING="$GOOSE_DBSTRING@localhost" + fi + fi + if [[ -n $MYSQL_DATABASE ]] ; then + GOOSE_DBSTRING="$GOOSE_DBSTRING/$MYSQL_DATABASE" + fi + export GOOSE_DBSTRING +fi +goose $*