From e5a0af1260c0e5d8ae753cb337fda91596958225 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 26 Jun 2009 17:26:18 +0000 Subject: [PATCH] Adding conditional check for column addition. --- docs/upgrades/upgrade_7.7.12-7.7.13.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/upgrades/upgrade_7.7.12-7.7.13.pl b/docs/upgrades/upgrade_7.7.12-7.7.13.pl index 1240485a7..87d1cd8f5 100644 --- a/docs/upgrades/upgrade_7.7.12-7.7.13.pl +++ b/docs/upgrades/upgrade_7.7.12-7.7.13.pl @@ -49,8 +49,11 @@ finish($session); # this line required # Describe what our function does sub addSessionTokenId { my $session = shift; - print "\tAdding CSRF token to session... " unless $quiet; - $session->db->write(q|ALTER TABLE userSession ADD COLUMN tokenId CHAR(22)|); + print "\tAdding CSRF token to userSession, if needed... " unless $quiet; + my $sth = $session->db->read('describe userSession tokenId'); + if (! defined $sth->hashRef) { + $session->db->write(q|ALTER TABLE userSession ADD COLUMN tokenId CHAR(22)|); + } # and here's our code print "DONE!\n" unless $quiet; }