killbill-aplcache
Changes
bin/db-helper 26(+13 -13)
Details
bin/db-helper 26(+13 -13)
diff --git a/bin/db-helper b/bin/db-helper
index d17568b..929c59a 100755
--- a/bin/db-helper
+++ b/bin/db-helper
@@ -19,7 +19,7 @@
# #
###################################################################################
-#set -x
+#set -x
HERE=`cd \`dirname $0\`; pwd`
TOP=$HERE/..
@@ -42,7 +42,7 @@ SKIP="(server)"
function usage() {
echo -n "./db_helper "
echo -n " -a <create|clean|dump>"
- echo -n " -d database_name (default = killbill)"
+ echo -n " -d database_name (default = killbill)"
echo -n " -u user_name (default = root)"
echo -n " -p password (default = root)"
echo -n " -t (also include test ddl)"
@@ -60,20 +60,20 @@ function get_modules() {
function find_test_ddl() {
local modules=`get_modules`
local ddl_test=
-
+
local cur_ddl=
for m in $modules; do
cur_ddl=`find $TOP/$m/src/test/resources/ -name ddl_test.sql 2>/dev/null`
ddl_test="$ddl_test $cur_ddl"
done
echo "$ddl_test"
-
+
}
function find_src_ddl() {
-
+
local modules=`get_modules`
local ddl_src=
-
+
local cur_ddl=
for m in $modules; do
cur_ddl=`find $TOP/$m/src/main/resources/ -name ddl.sql 2>/dev/null`
@@ -85,10 +85,10 @@ function find_src_ddl() {
function create_clean_file() {
local ddl_file=$1
- local tables=`cat $ddl_file | grep -i "create table" | awk ' { print $3 } '`
+ local tables=`cat $ddl_file | grep -i "create table" | awk ' { print $3 } '`
- local tmp="/tmp/clean-$DATABASE.$$"
- echo "use $DATABASE;" >> $tmp
+ local tmp="/tmp/clean-$DATABASE.$$"
+ echo "/*! use $DATABASE; */" >> $tmp
echo "" >> $tmp
for t in $tables; do
echo "truncate $t;" >> $tmp
@@ -106,7 +106,7 @@ function create_ddl_file() {
local tmp="/tmp/ddl-$DATABASE.$$"
touch $tmp
- echo "use $DATABASE;" >> $tmp
+ echo "/*! use $DATABASE; */" >> $tmp
echo "" >> $tmp
for d in $ddls; do
cat $d >> $tmp
@@ -152,13 +152,13 @@ fi
if [ $ACTION == "create" ]; then
DDL_FILE=`create_ddl_file`
- echo "Applying new schema $tmp to database $DATABASE"
+ echo "Applying new schema $tmp to database $DATABASE"
mysql -u $USER --password=$PWD < $DDL_FILE
fi
if [ $ACTION == "clean" ]; then
- DDL_FILE=`create_ddl_file`
- CLEAN_FILE=`create_clean_file $DDL_FILE`
+ DDL_FILE=`create_ddl_file`
+ CLEAN_FILE=`create_clean_file $DDL_FILE`
echo "Cleaning db tables on database $DATABASE"
mysql -u $USER --password=$PWD < $DDL_FILE
fi