Increase mail column size of Contacts quick tables

Fixes #4322
pull/218/merge
Francis Lachapelle 2017-10-24 14:19:25 -04:00
parent b56df72992
commit f5aeed444d
4 changed files with 76 additions and 3 deletions

View File

@ -76,7 +76,7 @@
},
{
columnName = c_mail;
sqlType = "VARCHAR2(255)";
sqlType = "CLOB";
allowsNull = YES;
},
{

View File

@ -76,7 +76,7 @@
},
{
columnName = c_mail;
sqlType = "VARCHAR(255)";
sqlType = "TEXT";
allowsNull = YES;
},
{

View File

@ -10,6 +10,11 @@ set -e
defaultusername=$USER
defaulthostname=127.0.0.1
defaultdatabase=sogo
indextable=$(sogo-tool dump-defaults -f /etc/sogo/sogo.conf | awk -F\" '/ OCSFolderInfoURL =/ {print $2}' | awk -F/ '{print $NF}')
if [ -z "$indextable" ]; then
echo "Couldn't fetch OCSFolderInfoURL value, aborting" >&2
exit 1
fi
read -p "Username ($defaultusername): " username
read -p "Hostname ($defaulthostname): " hostname
@ -42,8 +47,23 @@ function growUserProfile() {
IFS="$oldIFS"
}
echo "This script will ask for the sql password twice" >&2
function growContactsQuick() {
oldIFS="$IFS"
IFS=" "
part="`echo -e \"ALTER TABLE $table MODIFY c_mail text;\\n\"`";
sqlscript="$sqlscript$part"
IFS="$oldIFS"
}
echo "This script will ask for the database password twice" >&2
echo "Converting c_content from TEXT to LONGTEXT in the sogo_user_profile table" >&2
growUserProfile
echo "Converting c_mail from VARCHAR(255) to TEXT in Contacts quick tables" >&2
tables=`mysql -p -s -u $username -h $hostname $database -e "select SUBSTRING_INDEX(c_quick_location, '/', -1) from $indextable where c_path3 = 'Contacts';"`
for table in $tables;
do
growContactsQuick
done
echo "$sqlscript" | mysql -p -s -u $username -h $hostname $database

View File

@ -0,0 +1,53 @@
#!/bin/bash
set -e
# This script only works with PostgreSQL
# updates c_mail to text in Contacts quick table
# http://www.sogo.nu/bugs/view.php?id=4322
defaultusername=$USER
defaulthostname=localhost
defaultdatabase=sogo
indextable=$(sogo-tool dump-defaults -f /etc/sogo/sogo.conf | awk -F\" '/ OCSFolderInfoURL =/ {print $2}' | awk -F/ '{print $NF}')
if [ -z "$indextable" ]; then
echo "Couldn't fetch OCSFolderInfoURL value, aborting" >&2
exit 1
fi
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 growContactsQuick() {
oldIFS="$IFS"
IFS=" "
part="`echo -e \"ALTER TABLE $table ALTER COLUMN c_mail TYPE TEXT;\\n\"`";
sqlscript="$sqlscript$part"
IFS="$oldIFS"
}
echo "This script will ask for the database password twice" >&2
echo "Converting c_mail from VARCHAR(255) to TEXT in Contacts quick tables" >&2
tables=`psql -t -U $username -h $hostname $database -c "select split_part(c_quick_location, '/', 5) from $indextable where c_path3 = 'Contacts';"`
for table in $tables;
do
growContactsQuick
done
echo "$sqlscript" | psql -q -e -U $username -h $hostname $database