From 760f9d926abbcb19b86ff93ea2d32b69df463d41 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 19 Feb 2008 22:09:01 +0000 Subject: [PATCH] Add migrate helper for postgresql --- migration/migrate_postgresql.sh | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 migration/migrate_postgresql.sh diff --git a/migration/migrate_postgresql.sh b/migration/migrate_postgresql.sh new file mode 100644 index 0000000000..558e50aebd --- /dev/null +++ b/migration/migrate_postgresql.sh @@ -0,0 +1,36 @@ +#!/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 + +if [ -z "$1" ]; then + echo "Usage: $0 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 +done +if [ -d $1/../processes_post_migration/postgresql ] +then + for file in $1/../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;" +else + echo "ROLLBACK;" +fi +echo +echo "quit"