diff --git a/migration/migrate.sh b/migration/migrate.sh index 0e112370ff..e7aa6b8c4d 100644 --- a/migration/migrate.sh +++ b/migration/migrate.sh @@ -9,30 +9,44 @@ # Contributed by Chris Farley - northernbrewer +# CarlosRuiz - added multidirectory management 2008/02/20 + if [ -z "$1" ]; then - echo "Usage: $0 DIRECTORY [commit]" + echo "Usage: $0 [DIRECTORY ... DIRECTORY] [commit]" exit 0 fi echo "SET SQLBLANKLINES ON" echo "SET DEFINE OFF" 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' - echo +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;" + cat $file | dos2unix | sed 's/commit[ ]*;//I' + echo + done + fi done -if [ -d $1/../processes_post_migration ] +if [ -d $DIRINI/../processes_post_migration ] then - for file in $1/../processes_post_migration/*.sql; do + for file in $DIRINI/../processes_post_migration/*.sql; do echo "SELECT '`basename $file`' AS Filename FROM dual;" cat $file | dos2unix | sed 's/commit[ ]*;//I' echo done fi -if [ "$2" = "commit" ]; then - echo "COMMIT;" +if [ $COMMIT -eq 1 ] +then + echo "COMMIT;" else - echo "ROLLBACK;" + echo "ROLLBACK;" fi echo echo "quit" \ No newline at end of file diff --git a/migration/migrate_postgresql.sh b/migration/migrate_postgresql.sh index 558e50aebd..356029aa6b 100644 --- a/migration/migrate_postgresql.sh +++ b/migration/migrate_postgresql.sh @@ -10,27 +10,41 @@ # 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 [commit]" + echo "Usage: $0 [DIRECTORY ... DIRECTORY] [commit]" exit 0 fi -for file in $1/postgresql/*.sql; do - echo "SELECT '`basename $file`' AS Filename;" - cat $file | dos2unix | sed 's/commit[ ]*;//I' - echo +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;" + cat $file | dos2unix | sed 's/commit[ ]*;//I' + echo + done + fi done -if [ -d $1/../processes_post_migration/postgresql ] +if [ -d $DIRINI/../processes_post_migration/postgresql ] then - for file in $1/../processes_post_migration/postgresql/*.sql; do + for file in $DIRINI/../processes_post_migration/postgresql/*.sql; do echo "SELECT '`basename $file`' AS Filename;" cat $file | dos2unix | sed 's/commit[ ]*;//I' echo done fi -if [ "$2" = "commit" ]; then - echo "COMMIT;" +if [ $COMMIT -eq 1 ] +then + echo "COMMIT;" else - echo "ROLLBACK;" + echo "ROLLBACK;" fi echo echo "quit"