Posting partly because it might help someone else, and partly because I
figure y'all might be amused.
In a 0.10 installation, I had a typo in the summary field of a ticket.
Not finding a way to edit that within trac, I fired up psql and typed
something wrong, setting summary on all tickets because I forgot the
where ticket.id = 92. In a fit of further confusion, I also set
ticket.description on all tickets.
Nightly, we run pg_dumpall:
#!/bin/sh
cd /home/[me]/POSTGRESQL_BACKUP || exit 1
# Rotate old files.
for i in `seq 9 -1 0`; do
j=`expr $i + 1`
[ -f DUMP.$i ] && mv DUMP.$i DUMP.$j
done
(echo -n "-- Created on [host] at "; date;
pg_dumpall) \
> DUMP.0
So I grabbed that file, and loaded in on another machine. I then wrote
a perl script to create sql statements to fix the two borked fields,
leaving all other state alone, and sourced the output into psql on the
real server. I enclose it here in case it helps someone else.
I started to write a perl script to munge today's new ticket emails into
insert statements, but gave up and used emacs macros on the emails since
there were only 5 and that was faster.
#!/usr/bin/env perl
use strict;
use DBI;
my $dbh = DBI->connect("DBI:Pg:dbname=[redacted]", "[redacted]", "",
{ AutoCommit => 1 })
or die "db";
my $sth = $dbh->prepare("select id, summary, description from ticket;")
or die "prepare";
$sth->execute() or die "execute";
my @vector;
my($id, $summary, $description);
while (@vector = $sth->fetchrow) {
#printf "[%s] [%s]\n", @vector[0], @vector[1];
$id = @vector[0];
$summary = $dbh->quote(@vector[1]);
$description = $dbh->quote(@vector[2]);
printf "update ticket set summary = %s where ticket.id = %d;\n", $summary,
$id;
printf "update ticket set description = %s where ticket.id = %d;\n",
$description, $id;
}
$sth->finish();
$dbh->disconnect();
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/trac-users?hl=en
-~----------~----~----~----~------~----~------~--~---