File: /volume1/@appstore/MailClient/scripts/dump_drop_thread_label_table.sh
#!/bin/bash
MAIL_DB=$1
TABLE="many_thread_has_many_label"
DumpAndDropTable() {
local db_dir=`dirname ${MAIL_DB}`
local bak_file="${db_dir}/${TABLE}.bak"
local res=`sqlite3 $MAIL_DB ".dump ${TABLE}" > $bak_file`
if [ $? -ne 0 ]; then
exit 1;
fi
local size=`stat -c%s ${bak_file}`
if [ $? -ne 0 ] || [ $size -lt 53 ]; then
exit 1
fi
sqlite3 $MAIL_DB "DROP TABLE IF EXISTS ${TABLE}"
}
if [ ! -f "$MAIL_DB" ];then
echo "Usage: $0 db_path"
exit 1
fi
DumpAndDropTable
exit 0