From d99e4cc41596f2bfe4e54116cf4c03aeffc595e2 Mon Sep 17 00:00:00 2001 From: khenn Date: Mon, 17 May 2010 09:59:51 -0500 Subject: [PATCH] put checks in before alter groupGroupings table --- docs/upgrades/upgrade_7.9.4-7.9.5.pl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/upgrades/upgrade_7.9.4-7.9.5.pl b/docs/upgrades/upgrade_7.9.4-7.9.5.pl index 22d7305fa..bc84dffd0 100644 --- a/docs/upgrades/upgrade_7.9.4-7.9.5.pl +++ b/docs/upgrades/upgrade_7.9.4-7.9.5.pl @@ -62,11 +62,19 @@ sub addRejectNoticeSetting { sub updateGroupGroupingsTable { my $session = shift; print "\tAdding primary key and indicies to groupGroupings table... " unless $quiet; - $session->db->write("alter table groupGroupings add primary key (groupId,inGroup)"); - $session->db->write("alter table groupGroupings add index inGroup (inGroup)"); + my $sth = $session->db->read('show create table groupGroupings'); + my ($field,$stmt) = $sth->array; + $sth->finish; + unless ($stmt =~ m/PRIMARY KEY/i) { + $session->db->write("alter table groupGroupings add primary key (groupId,inGroup)"); + } + unless ($stmt =~ m/KEY `inGroup`/i) { + $session->db->write("alter table groupGroupings add index inGroup (inGroup)"); + } print "DONE!\n" unless $quiet; } + #---------------------------------------------------------------------------- # Describe what our function does sub fixRequestForApprovalScratch {