Little enhancements to migrate.sh script

- convert from dos to unix
- spool
This commit is contained in:
Carlos Ruiz 2007-04-14 21:34:13 +00:00
parent 484507369c
commit a66a58a232
1 changed files with 29 additions and 27 deletions

View File

@ -1,27 +1,29 @@
#!/bin/sh
# This formats all the SQL files in the specified directory so that
# they can be executed by SQL*Plus. There are two modes -- a 'testing'
# mode (the default mode -- this stips out all the "commit" statements)
# and a commit mode for deployment. You need to pipe the output of this
# script into sqlplus, for example:
# ./migrate.sh 313-314 commit | sqlplus compiere/compiere
# Contributed by Chris Farley - northernbrewer
if [ -z "$1" ]; then
echo "Usage: migrate DIRECTORY [commit]"
exit 0
fi
echo "SET SQLBLANKLINES ON;"
echo "SET DEFINE OFF;"
for file in `ls $1`; do
echo "SELECT '$file' AS Filename FROM dual;"
cat $1/$file | sed 's/commit[ ]*;//I'
echo
done
if [ "$2" = "commit" ]; then
echo "COMMIT;"
else
echo "ROLLBACK;"
fi
#!/bin/sh
# This formats all the SQL files in the specified directory so that
# they can be executed by SQL*Plus. There are two modes -- a 'testing'
# mode (the default mode -- this stips out all the "commit" statements)
# and a commit mode for deployment. You need to pipe the output of this
# script into sqlplus, for example:
# ./migrate.sh 313-314 commit | sqlplus adempiere/adempiere
# Contributed by Chris Farley - northernbrewer
if [ -z "$1" ]; then
echo "Usage: $0 DIRECTORY [commit]"
exit 0
fi
echo "SET SQLBLANKLINES ON"
echo "SET DEFINE OFF"
echo "SPOOL $1"
for file in `ls $1`; do
echo "SELECT '$file' AS Filename FROM dual;"
dos2unix $1/$file
cat $1/$file | sed 's/commit[ ]*;//I'
echo
done
if [ "$2" = "commit" ]; then
echo "COMMIT;"
else
echo "ROLLBACK;"
fi