mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-07 22:38:51 +00:00
Added sql-update-1.2.2_to_1.3.0-mysql.sh and modified
the spec file and the debian file to include it Monotone-Parent: d486d5e829cf0bc377649b3e2d2ecfcc08afb8e8 Monotone-Revision: 3bf253d3d887017200751e451da4fd1a31cc57ce Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2010-07-15T15:03:35 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
45
Scripts/sql-update-1.2.2_to_1.3.0-mysql.sh
Executable file
45
Scripts/sql-update-1.2.2_to_1.3.0-mysql.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
# this script only works with MySQL
|
||||
|
||||
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=`mysql -p -N -B -u $username -h $hostname $database -e "select SUBSTRING_INDEX(c_quick_location, '/', -1) from $indextable where c_folder_type = 'Appointment';"`
|
||||
|
||||
for table in $tables;
|
||||
do
|
||||
addField
|
||||
done
|
||||
echo "$sqlscript" | mysql -p -s -u $username -h $hostname $database > /dev/null
|
||||
Reference in New Issue
Block a user