put checks in before alter groupGroupings table

This commit is contained in:
khenn 2010-05-17 09:59:51 -05:00
parent f852bd8866
commit d99e4cc415

View file

@ -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 {