merge of '379924109229c07d133fc063329a33e5f0dc987d'

and 'b8548824eb65ecdb685bcfce0f1f1a07d6e8f2c0'

Monotone-Parent: 379924109229c07d133fc063329a33e5f0dc987d
Monotone-Parent: b8548824eb65ecdb685bcfce0f1f1a07d6e8f2c0
Monotone-Revision: e3a548e4955e0964c4a0211759ff98c585efda44

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2012-01-03T21:45:31
This commit is contained in:
Francis Lachapelle
2012-01-03 21:45:31 +00:00
2 changed files with 45 additions and 1 deletions
+1 -1
View File
@@ -258,7 +258,7 @@
static NSString *sqlFolderFormat
= (@"CREATE TABLE %@ (\n"
@" c_name VARCHAR (255) NOT NULL PRIMARY KEY,\n"
@" c_content TEXT NOT NULL,\n"
@" c_content MEDIUMTEXT NOT NULL,\n"
@" c_creationdate INT NOT NULL,\n"
@" c_lastmodified INT NOT NULL,\n"
@" c_version INT NOT NULL,\n"
+44
View File
@@ -0,0 +1,44 @@
#!/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 convVCtoText() {
oldIFS="$IFS"
IFS=" "
part="`echo -e \"ALTER TABLE $table ALTER COLUMN c_content TYPE TEXT;\\n\"`";
sqlscript="$sqlscript$part"
IFS="$oldIFS"
}
tables=`psql -t -U $username -h $hostname $database -c "select split_part(c_location, '/', 5) from $indextable;"`
for table in $tables;
do
convVCtoText
done
echo "$sqlscript" | psql -q -e -U $username -h $hostname $database