From: Vincent Bernat <bernat@debian.org> Date: Sun, 13 Feb 2011 12:45:23 +0000 (+0000) Subject: Fix MySQL indexes if upgrading from 0.5-2 or lesser. Closes: #610725. X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=abd475b46d1196f0fb28dfbdf9e1dc3615c89f82;p=roundcube.git Fix MySQL indexes if upgrading from 0.5-2 or lesser. Closes: #610725. --- diff --git a/debian/changelog b/debian/changelog index 0aa6e75..c5004c8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,7 @@ roundcube (0.5-3) UNRELEASED; urgency=low * Add instructions on how to install and upgrade when not using dbconfig-common. We do not ship UPGRADING file any more since it is misleading. Closes: #612511. + * Fix MySQL indexes if upgrading from 0.5-2 or lesser. Closes: #610725. -- Vincent Bernat <bernat@debian.org> Wed, 09 Feb 2011 07:32:42 +0100 diff --git a/debian/roundcube-core.postinst b/debian/roundcube-core.postinst index c1968a6..f4e2a82 100644 --- a/debian/roundcube-core.postinst +++ b/debian/roundcube-core.postinst @@ -39,6 +39,27 @@ apache_install() { case "$1" in configure) + # We try to fix an incomplete upgrade (see #610725) + if [ -n "$2" ] && dpkg --compare-versions "$2" le 0.5-2; then + db_get roundcube/dbconfig-upgrade || true + if [ x"$RET" = x"true" ]; then + # Ok, we may need to do some upgrade steps. Let's get + # database parameters + eval `sed -n 's/^\$\(.*\);$/\1/p' /etc/roundcube/debian-db.php` + if [ x"$dbtype" = x"mysql" ]; then + echo "Fixing MySQL indexes (you can ignore errors)..." + MYSQLARGS="-f -u $dbuser -p$dbpass $dbname" + [ -z "$dbserver" ] || MYSQLARGS="-h $dbserver $MYSQLARGS" + [ -z "$dbport" ] || MYSQLARGS="-P $dbport $MYSQLARGS" + cat <<EOF | mysql $MYSQLARGS || true +ALTER TABLE \`messages\` ADD INDEX \`index_index\` (\`user_id\`, \`cache_key\`, \`idx\`); +ALTER TABLE \`session\` CHANGE \`vars\` \`vars\` MEDIUMTEXT NOT NULL; +ALTER TABLE \`contacts\`ADD INDEX \`user_contacts_index\` (\`user_id\`,\`email\`); +EOF + fi + fi + fi + CONFFILE=/etc/roundcube/main.inc.php touch $CONFFILE.ucftmp chmod 640 $CONFFILE.ucftmp