From 6c21591e54839d203f5706b89dfd7555310ac3c6 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 24 Aug 2007 18:47:41 +0000 Subject: [PATCH] Monotone-Parent: c0a9477f1eb52db3cc79a428d99ba7227f71fa3c Monotone-Revision: 0bde24af2d54dcd7bdb9395dcc3baf170b2a7d03 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-08-24T18:47:41 Monotone-Branch: ca.inverse.sogo --- Scripts/sql-update-20070822.sh | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Scripts/sql-update-20070822.sh b/Scripts/sql-update-20070822.sh index a8014c7ac..80a41a2bd 100755 --- a/Scripts/sql-update-20070822.sh +++ b/Scripts/sql-update-20070822.sh @@ -46,5 +46,25 @@ do addField done -sqlscript="$sqlscript;" -echo "$sqlscript" | psql -e -U $username -h $hostname $database +sqlscript="$sqlscript;update $indextable set c_path4 = 'personal', c_path = '/Users/' || c_path2 || '/Calendar/personal' where c_path3 = 'Calendar' and c_path4 is null;" + +function updateCalendarLocation() { + oldIFS="$IFS" + IFS=" " + user="`echo $table | cut -f 1 -d :`" + tablename="`echo $table | cut -f 2 -d :`" + newstart="/$user/Calendar/personal"; + part="update $tablename set c_object = replace(c_object, '/$user/Calendar', '$newstart') where c_object not like '$newstart%';"; + sqlscript="$sqlscript$part" + IFS="$oldIFS" +} + +tables=`psql -t -U $username -h $hostname $database -c "select c_path2 || ':' || split_part(c_acl_location, '/', 5) from $indextable where c_folder_type = 'Appointment';"` +for table in $tables; +do + updateCalendarLocation +done + +echo "$sqlscript" | psql -q -e -U $username -h $hostname $database > /dev/null + +echo "Please ignore the errors above. They just mean that the migration was already done for the elements in question."; \ No newline at end of file