(feat) new c_hascertificate column in contact quick tables and migration scripts
parent
6c993be9f1
commit
f662781312
|
@ -104,5 +104,10 @@
|
||||||
sqlType = "VARCHAR2(10)";
|
sqlType = "VARCHAR2(10)";
|
||||||
allowsNull = NO;
|
allowsNull = NO;
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
columnName = c_hascertificate;
|
||||||
|
sqlType = "INTEGER";
|
||||||
|
allowsNull = YES;
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,5 +104,10 @@
|
||||||
sqlType = "VARCHAR(10)";
|
sqlType = "VARCHAR(10)";
|
||||||
allowsNull = NO;
|
allowsNull = NO;
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
columnName = c_hascertificate;
|
||||||
|
sqlType = "INT";
|
||||||
|
allowsNull = YES;
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# This script only works with MySQL
|
# This script only works with MySQL - it does:
|
||||||
# updates c_defaults and c_settings to longtext in the sogo_user_profile table
|
#
|
||||||
|
# 1- updates c_defaults and c_settings to longtext in the sogo_user_profile table
|
||||||
# to avoid truncation of data at 64k
|
# to avoid truncation of data at 64k
|
||||||
|
# 2- increase the c_mail column to text to contact quick table
|
||||||
|
# 3- add the c_hascertificate column to contact quick table
|
||||||
|
|
||||||
defaultusername=$USER
|
defaultusername=$USER
|
||||||
defaulthostname=127.0.0.1
|
defaulthostname=127.0.0.1
|
||||||
|
@ -47,7 +49,7 @@ function growUserProfile() {
|
||||||
IFS="$oldIFS"
|
IFS="$oldIFS"
|
||||||
}
|
}
|
||||||
|
|
||||||
function growContactsQuick() {
|
function growMailInContactsQuick() {
|
||||||
oldIFS="$IFS"
|
oldIFS="$IFS"
|
||||||
IFS=" "
|
IFS=" "
|
||||||
part="`echo -e \"ALTER TABLE $table MODIFY c_mail text;\\n\"`";
|
part="`echo -e \"ALTER TABLE $table MODIFY c_mail text;\\n\"`";
|
||||||
|
@ -55,6 +57,15 @@ function growContactsQuick() {
|
||||||
IFS="$oldIFS"
|
IFS="$oldIFS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addCertificateInContactsQuick() {
|
||||||
|
oldIFS="$IFS"
|
||||||
|
IFS=" "
|
||||||
|
part="`echo -e \"ALTER TABLE $table ADD c_hascertificate INT4 DEFAULT 0;\\n\"`";
|
||||||
|
sqlscript="$sqlscript$part"
|
||||||
|
IFS="$oldIFS"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
echo "This script will ask for the database password twice" >&2
|
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
|
echo "Converting c_content from TEXT to LONGTEXT in the sogo_user_profile table" >&2
|
||||||
growUserProfile
|
growUserProfile
|
||||||
|
@ -63,7 +74,8 @@ 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';"`
|
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;
|
for table in $tables;
|
||||||
do
|
do
|
||||||
growContactsQuick
|
growMailInContactsQuick
|
||||||
|
addCertificateInContactsQuick
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "$sqlscript" | mysql -p -s -u $username -h $hostname $database
|
echo "$sqlscript" | mysql -p -s -u $username -h $hostname $database
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
# This script only works with PostgreSQL
|
|
||||||
# updates c_mail to text in Contacts quick table
|
# This script only works with PostgreSQL - it does:
|
||||||
# http://www.sogo.nu/bugs/view.php?id=4322
|
#
|
||||||
|
# 1- increase the c_mail column to text to contact quick table
|
||||||
|
# 2- add the c_hascertificate column to contact quick table
|
||||||
|
|
||||||
defaultusername=$USER
|
defaultusername=$USER
|
||||||
defaulthostname=localhost
|
defaulthostname=localhost
|
||||||
|
@ -33,7 +35,7 @@ fi
|
||||||
|
|
||||||
sqlscript=""
|
sqlscript=""
|
||||||
|
|
||||||
function growContactsQuick() {
|
function growMailInContactsQuick() {
|
||||||
oldIFS="$IFS"
|
oldIFS="$IFS"
|
||||||
IFS=" "
|
IFS=" "
|
||||||
part="`echo -e \"ALTER TABLE $table ALTER COLUMN c_mail TYPE TEXT;\\n\"`";
|
part="`echo -e \"ALTER TABLE $table ALTER COLUMN c_mail TYPE TEXT;\\n\"`";
|
||||||
|
@ -41,13 +43,22 @@ function growContactsQuick() {
|
||||||
IFS="$oldIFS"
|
IFS="$oldIFS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addCertificateInContactsQuick() {
|
||||||
|
oldIFS="$IFS"
|
||||||
|
IFS=" "
|
||||||
|
part="`echo -e \"ALTER TABLE $table ADD c_hascertificate INT4 DEFAULT 0;\\n\"`";
|
||||||
|
sqlscript="$sqlscript$part"
|
||||||
|
IFS="$oldIFS"
|
||||||
|
}
|
||||||
|
|
||||||
echo "This script will ask for the database password twice" >&2
|
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
|
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';"`
|
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;
|
for table in $tables;
|
||||||
do
|
do
|
||||||
growContactsQuick
|
growMailInContactsQuick
|
||||||
|
addCertificateInContactsQuick
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "$sqlscript" | psql -q -e -U $username -h $hostname $database
|
echo "$sqlscript" | psql -q -e -U $username -h $hostname $database
|
||||||
|
|
Loading…
Reference in New Issue