[imp] IMP 2.2.x to 3.0.x DataBase Upgrade
Brian Helman
bhelman@salemstate.edu
Thu, 17 Jan 2002 12:10:53 -0500
Ok. I think I have imp2horde.pl correctly configured for postrgreSQL
rather than MySQL. When I first ran it, I received an error that it
couldn't find DBI.pm . I installed perl-DBI-1.18-1.i386.rpm (RH 7.2) and
now it is looking for pgsql.pm . I have not been able to find this file.
I know people are very busy with more serious matters, but here is my
imp2horde.pl script. Did I miss something?
#!/usr/bin/perl
#
# $Horde: imp/scripts/imp2horde.pl,v 1.2.2.2 2001/12/24 17:23:38 chuck Exp $
#
# File: imp2horde.pl
# Author: Christophe Guilloux - rootix@bootix.net
# Version: 1.0
#
# Date: 4/12/01
# History: code taken from imp2turba.pl and adapted to imp2horde.pl
# Purpose: This script converts an old imp preferences database contents
# to the newer horde table format, it was written for
# mysql, but could be easily ported to other databases
#
# Usage: Modify the variables at the beginning of the script
# so that your database user/password, location and imp
# database and horde database are correct.
#
use DBI;
our $location = 'xxxxxxxxxxx';
our $port_num = '5432';
our $username = 'xxxxxxxxxx';
our $password = 'xxxxxxx';
our $IMP_DATABASE = 'horde';
our $IMP_TABLE = 'imp_pref';
our $HORDE_DATABASE = 'horde2';
our $HORDE_TABLE = 'horde_prefs';
our $domain = 'salemstate.edu';
our $dbi_options = {RaiseError => 1, ChopBlanks => 1, AutoCommit => 1};
$db_imphandle = DBI->connect
("DBI:pgsql:$IMP_DATABASE:$location:port_num",
$username, $password, $dbi_options )
|| die ("Connection error: $DBI::errstr");
$db_horde = DBI->connect
("DBI:pgsql:$HORDE_DATABASE",
$username, $password, $dbi_options )
|| die ("Connection error: $DBI::errstr");
$imp_statement = $db_imphandle->prepare("SELECT * FROM $IMP_TABLE");
$imp_statement->execute();
$horde_statement = "DELETE FROM $HORDE_TABLE";
$horde_statement = $db_horde->prepare($horde_statement)
|| die "prepare: $$stmt: $DBI::errstr";
$horde_statement->execute || die "execute: $$stmt: $DBI::errstr";
while (my ($owner, $fullname, $replyto, $lang, $sig) =
$imp_statement->fetchrow_array())
{
#@chars = ( "A" .. "Z", "a" .. "z", 0 .. 9, qw(! @ $ % ^ & *) );
#$unique_key = join("", @chars[ map { rand @chars } ( 1 .. 31 ) ]);
# Remove the @domain.com part from the $owner, doesn't work in Turba
$owner =~ s/\@.*$//;
$owner .= "\@$domain";
my $quoted_owner = $db_imphandle->quote($owner);
my $quoted_fullname = $db_imphandle->quote($fullname);
my $value = "a:1:{i:0;a:12:{s:2:\"id\";s:19:\"Identiti par
difaut\";s:8:\"fu
llname\";s:".length($fullname).":\"$fullname\";s:9:\"from_addr\";s:0:\"\";s:12:\
"replyto_addr\";s:".length($replyto).":\"$replyto\";s:9:\"signature\";s:".length
($sig).":\"$sig\";s:9:\"sig_first\";i:0;s:10:\"sig_dashes\";s:1:\"1\";s:14:\"sav
e_sent-mail\";N;s:16:\"sent_mail_folder\";s:15:\"INBOX.sent-mail\";s:14:\"save_s
ent_mail\";s:1:\"1\";s:11:\"private_key\";N;s:16:\"private_key_type\";N;}}";
my $quoted_value = $db_horde->quote($value);
#print "$value\n";
$horde_statement = "INSERT INTO $HORDE_TABLE VALUES
($quoted_owner, 'horde', 'identities',
$quoted_value)";
$horde_statement = $db_horde->prepare($horde_statement)
|| die "prepare: $$stmt: $DBI::errstr";
$horde_statement->execute || die "execute: $$stmt: $DBI::errstr";
$horde_statement->finish();
}
$imp_statement->finish();
$horde_statement->finish();
$db_imphandle->disconnect;
$db_horde->disconnect;
At 05:10 PM 1/15/02 -0500, you wrote:
>Check out /horde/scripts/db/ for SQL to build new tables.
>/horde/imp/scripts/db/ as well.
>
>
> > -----Original Message-----
> > From: Brian Helman [mailto:bhelman@salemstate.edu]
> > Sent: Tuesday, January 15, 2002 4:29 PM
> > To: imp@lists.horde.org
> > Subject: [imp] IMP 2.2.x to 3.0.x DataBase Upgrade
> >
> >
> >
> > Is it possible to upgrade the IMP 2.2 database to 3.0?
> >
>
>
>--
>IMP mailing list: http://horde.org/imp/
>Archive: http://marc.theaimsgroup.com/?l=imp&r=1&w=2
>Frequently Asked Questions: http://horde.org/faq/
>To unsubscribe, mail: imp-unsubscribe@lists.horde.org
------------------------------------------------------
__ ____ __ ____ __ __
/\ \ / \_\ / /\ / \ \ / |\ / /\
/ \_\ / /\ |_| / / /| /\ \ \ / ||/ / /
/ /\ | |\ \/ /_/_ / / / \ \/ \ \ / |/ / /
/ \/ |_| \ __ \_\ / / / \ /\ \_\ / /| / /
/ /\ ./_/ \ \ \/_// / / \ \ \/_// / | / /
\ \/ |_| \ \_\ /_/ / \ \_\ /_/ /|_/ /
\__/_/ \/_/ \_\/ \/_/ \_\/ \_\/
Brian M Helman
Director, Networking Services
Salem State College
Voice: 978.542.7272
Fax: 978.542.6620
e-mail: bhelman@salemstate.edu
snail-mail: 352 Lafayette St, MH207A
Salem, MA 01970-5353
http://www.helman.nu/