sogo/Scripts/sql-update-1.2.2_to_1.3.0.sh
Ludovic Marcotte ba1e5eb172 Renamed the update script to 1.3.0 instead of 1.2.3. Also adjusted
the spec file and the debian docs file to reflect that change.

Monotone-Parent: fadda581fd1abe4d86b55b0e83a0de4f42e41119
Monotone-Revision: fcaffd578bcbd7038ac7318f0436491a6b5b04b6

Monotone-Author: ludovic@Sophos.ca
Monotone-Date: 2010-07-14T18:42:54
Monotone-Branch: ca.inverse.sogo
2010-07-14 18:42:54 +00:00

45 lines
958 B
Bash
Executable file

#!/bin/bash
# this script only works with PostgreSQL
defaultusername=$USER
defaulthostname=localhost
defaultdatabase=$USER
indextable=sogo_folder_info
read -p "Username ($defaultusername): " username
read -p "Hostname ($defaulthostname): " hostname
read -p "Database ($defaultdatabase): " database
if [ -z "$username" ]
then
username=$defaultusername
fi
if [ -z "$hostname" ]
then
hostname=$defaulthostname
fi
if [ -z "$database" ]
then
database=$defaultdatabase
fi
sqlscript=""
function addField() {
oldIFS="$IFS"
IFS=" "
part="`echo -e \"ALTER TABLE $table ADD COLUMN c_category VARCHAR(255);\\n\"`";
sqlscript="$sqlscript$part"
IFS="$oldIFS"
}
tables=`psql -t -U $username -h $hostname $database -c "select split_part(c_quick_location, '/', 5) from $indextable where c_folder_type = 'Appointment';"`
for table in $tables;
do
addField
done
echo "$sqlscript" | psql -q -e -U $username -h $hostname $database > /dev/null