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
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "Usage: $0 DIRECTORY [commit]"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
echo "SET SQLBLANKLINES ON"
|
|
|
|
echo "SET DEFINE OFF"
|
2008-01-23 23:20:03 +07:00
|
|
|
echo "SPOOL `basename $1`"
|
|
|
|
for file in $1/*.sql; do
|
|
|
|
echo "SELECT '`basename $file`' AS Filename FROM dual;"
|
|
|
|
cat $file | dos2unix | sed 's/commit[ ]*;//I'
|
2007-04-15 04:34:13 +07:00
|
|
|
echo
|
|
|
|
done
|
2008-01-23 23:20:03 +07:00
|
|
|
if [ -d $1/../processes_post_migration ]
|
|
|
|
then
|
|
|
|
for file in $1/../processes_post_migration/*.sql; do
|
|
|
|
echo "SELECT '`basename $file`' AS Filename FROM dual;"
|
|
|
|
cat $file | dos2unix | sed 's/commit[ ]*;//I'
|
|
|
|
echo
|
|
|
|
done
|
|
|
|
fi
|
2007-04-15 04:34:13 +07:00
|
|
|
if [ "$2" = "commit" ]; then
|
|
|
|
echo "COMMIT;"
|
|
|
|
else
|
|
|
|
echo "ROLLBACK;"
|
|
|
|
fi
|
2008-01-23 23:20:03 +07:00
|
|
|
echo
|
|
|
|
echo "quit"
|