2007-04-15 04:34:13 +07:00
|
|
|
#!/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'
|
2008-01-17 11:42:10 +07:00
|
|
|
# mode (the default mode -- this strips out all the "commit" statements)
|
2007-04-15 04:34:13 +07:00
|
|
|
# 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
|
|
|
|
|
2008-02-21 05:39:29 +07:00
|
|
|
# CarlosRuiz - added multidirectory management 2008/02/20
|
|
|
|
|
2007-04-15 04:34:13 +07:00
|
|
|
if [ -z "$1" ]; then
|
2008-02-21 05:39:29 +07:00
|
|
|
echo "Usage: $0 [DIRECTORY ... DIRECTORY] [commit]"
|
2007-04-15 04:34:13 +07:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
echo "SET SQLBLANKLINES ON"
|
|
|
|
echo "SET DEFINE OFF"
|
2008-01-23 23:20:03 +07:00
|
|
|
echo "SPOOL `basename $1`"
|
2008-02-21 05:39:29 +07:00
|
|
|
DIRINI=$1
|
|
|
|
COMMIT=0
|
|
|
|
while [ $# -gt 0 ]
|
|
|
|
do
|
|
|
|
DIR=$1
|
|
|
|
shift
|
|
|
|
if [ "$DIR" = "commit" ]; then
|
|
|
|
COMMIT=1
|
|
|
|
else
|
|
|
|
for file in $DIR/*.sql; do
|
|
|
|
echo "SELECT '`basename $file`' AS Filename FROM dual;"
|
2008-05-31 09:43:50 +07:00
|
|
|
echo
|
2008-05-31 10:40:49 +07:00
|
|
|
cat $file | dos2unix
|
2008-02-21 05:39:29 +07:00
|
|
|
echo
|
2008-05-31 09:43:50 +07:00
|
|
|
echo
|
2008-02-21 05:39:29 +07:00
|
|
|
done
|
|
|
|
fi
|
2007-04-15 04:34:13 +07:00
|
|
|
done
|
2008-02-21 05:39:29 +07:00
|
|
|
if [ -d $DIRINI/../processes_post_migration ]
|
2008-01-23 23:20:03 +07:00
|
|
|
then
|
2008-02-21 05:39:29 +07:00
|
|
|
for file in $DIRINI/../processes_post_migration/*.sql; do
|
2008-01-23 23:20:03 +07:00
|
|
|
echo "SELECT '`basename $file`' AS Filename FROM dual;"
|
2008-05-31 09:43:50 +07:00
|
|
|
echo
|
2008-05-31 10:40:49 +07:00
|
|
|
cat $file | dos2unix
|
2008-01-23 23:20:03 +07:00
|
|
|
echo
|
2008-05-31 09:43:50 +07:00
|
|
|
echo
|
2008-01-23 23:20:03 +07:00
|
|
|
done
|
|
|
|
fi
|
2008-03-17 21:29:43 +07:00
|
|
|
if [ -d $DIRINI/../my_processes_post_migration ]
|
|
|
|
then
|
|
|
|
for file in $DIRINI/../my_processes_post_migration/*.sql; do
|
|
|
|
echo "SELECT '`basename $file`' AS Filename FROM dual;"
|
2008-05-31 09:43:50 +07:00
|
|
|
echo
|
2008-05-31 10:40:49 +07:00
|
|
|
cat $file | dos2unix
|
2008-03-17 21:29:43 +07:00
|
|
|
echo
|
2008-05-31 09:43:50 +07:00
|
|
|
echo
|
2008-03-17 21:29:43 +07:00
|
|
|
done
|
|
|
|
fi
|
2008-02-21 05:39:29 +07:00
|
|
|
if [ $COMMIT -eq 1 ]
|
|
|
|
then
|
|
|
|
echo "COMMIT;"
|
2007-04-15 04:34:13 +07:00
|
|
|
else
|
2008-02-21 05:39:29 +07:00
|
|
|
echo "ROLLBACK;"
|
2007-04-15 04:34:13 +07:00
|
|
|
fi
|
2008-01-23 23:20:03 +07:00
|
|
|
echo
|
2008-05-31 09:43:50 +07:00
|
|
|
echo "quit"
|