From 532266955ec074fc593e044fdc2ba5706f87b316 Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Thu, 5 Apr 2018 15:11:37 -0300 Subject: [PATCH] Corrige script para normalizar dumps do legado --- sapl/legacy/scripts/normaliza_dump_mysql.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sapl/legacy/scripts/normaliza_dump_mysql.sh b/sapl/legacy/scripts/normaliza_dump_mysql.sh index 79315252d..75bd5435f 100755 --- a/sapl/legacy/scripts/normaliza_dump_mysql.sh +++ b/sapl/legacy/scripts/normaliza_dump_mysql.sh @@ -1,7 +1,7 @@ #!/bin/bash ARQUIVO=$1 -BANCO=`echo $1 | cut -f1 -d.` +BANCO=`basename $1 | cut -f1 -d.` TMP=__tmp.sql cat << EOF > $TMP @@ -17,10 +17,12 @@ cat << EOF > $TMP /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +/*!40000 DROP DATABASE IF EXISTS \`$BANCO\`*/; + +CREATE DATABASE /*!32312 IF NOT EXISTS*/ \`$BANCO\` /*!40100 DEFAULT CHARACTER SET latin1 */; + +USE \`$BANCO\`; EOF -echo "CREATE DATABASE /*!32312 IF NOT EXISTS*/ \`$BANCO\` /*!40100 DEFAULT CHARACTER SET latin1 */;" >> $TMP -echo >> $TMP -echo "USE \`$BANCO\`;" >> $TMP sed 1,`grep -n '^USE ' $ARQUIVO |cut -f1 -d:`d $ARQUIVO >> $TMP mv $TMP $ARQUIVO