From cef44bf38efbda57ab33479eb5637771c2336bd5 Mon Sep 17 00:00:00 2001 From: "Redhuan D. Oon" Date: Thu, 18 Dec 2008 00:07:09 +0000 Subject: [PATCH] REVERTING REVISION of [ FR 2432892 ] Re-org of migration directory --- migration/migrate.sh | 66 +++++++++++++++++++++++++++++++++ migration/migrate_postgresql.sh | 64 ++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 migration/migrate.sh create mode 100644 migration/migrate_postgresql.sh diff --git a/migration/migrate.sh b/migration/migrate.sh new file mode 100644 index 0000000000..9d4f6c9213 --- /dev/null +++ b/migration/migrate.sh @@ -0,0 +1,66 @@ +#!/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 strips 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 + +# CarlosRuiz - added multidirectory management 2008/02/20 + +if [ -z "$1" ]; then + echo "Usage: $0 [DIRECTORY ... DIRECTORY] [commit]" + exit 0 +fi +echo "SET SQLBLANKLINES ON" +echo "SET DEFINE OFF" +echo "SPOOL `basename $1`" +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;" + echo + cat $file | dos2unix + echo + echo + done + fi +done +if [ -d $DIRINI/../processes_post_migration ] +then + for file in $DIRINI/../processes_post_migration/*.sql; do + echo "SELECT '`basename $file`' AS Filename FROM dual;" + echo + cat $file | dos2unix + echo + echo + done +fi +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;" + echo + cat $file | dos2unix + echo + echo + done +fi +if [ $COMMIT -eq 1 ] +then + echo "COMMIT;" +else + echo "ROLLBACK;" +fi +echo +echo "quit" diff --git a/migration/migrate_postgresql.sh b/migration/migrate_postgresql.sh new file mode 100644 index 0000000000..a0f7ef5751 --- /dev/null +++ b/migration/migrate_postgresql.sh @@ -0,0 +1,64 @@ +#!/bin/sh + +# This formats all the SQL files in the specified directory so that +# they can be executed by psql. There are two modes -- a 'testing' +# mode (the default mode -- this strips 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 | psql -U adempiere -d adempiere > 313-314.lst + +# Original contribution by by Chris Farley - northernbrewer +# Adapted to postgresql by Carlos Ruiz - globalqss + +# CarlosRuiz - added multidirectory management 2008/02/20 + +if [ -z "$1" ]; then + echo "Usage: $0 [DIRECTORY ... DIRECTORY] [commit]" + exit 0 +fi +DIRINI=$1 +COMMIT=0 +while [ $# -gt 0 ] +do + DIR=$1 + shift + if [ "$DIR" = "commit" ]; then + COMMIT=1 + else + for file in $DIR/postgresql/*.sql; do + echo "SELECT '`basename $file`' AS Filename;" + echo + cat $file | dos2unix | sed 's/commit[ ]*;//I' + echo + echo + done + fi +done +if [ -d $DIRINI/../processes_post_migration/postgresql ] +then + for file in $DIRINI/../processes_post_migration/postgresql/*.sql; do + echo "SELECT '`basename $file`' AS Filename;" + echo + cat $file | dos2unix | sed 's/commit[ ]*;//I' + echo + echo + done +fi +if [ -d $DIRINI/../my_processes_post_migration/postgresql ] +then + for file in $DIRINI/../my_processes_post_migration/postgresql/*.sql; do + echo "SELECT '`basename $file`' AS Filename;" + echo + cat $file | dos2unix | sed 's/commit[ ]*;//I' + echo + echo + done +fi +if [ $COMMIT -eq 1 ] +then + echo "COMMIT;" +else + echo "ROLLBACK;" +fi +echo +echo "\quit"