Rekey the template_attachments table. Fixes bug #11063.

Also, prevent template attachments from throwing an error on duplicate
URLs, and fix the purge method added earlier.
This commit is contained in:
Colin Kuskie 2009-10-21 16:11:22 -07:00
parent 13f833c27b
commit ece9d56a9e
4 changed files with 33 additions and 14 deletions

View file

@ -3,6 +3,7 @@
- fixed #11152: Image edits do not autocommit version tags
- fixed template attachments are not cleaned up during purge
- fixed #11150: matrix - search boxes all ticked
- fixed #11063: template_attachments
7.8.2
- Added scheduled vendor payout workflow activity. (Special thanks to Martin @ Oqapi)

View file

@ -31,12 +31,30 @@ my $quiet; # this line required
my $session = start(); # this line required
# upgrade functions go here
reKeyTemplateAttachments($session);
finish($session); # this line required
#----------------------------------------------------------------------------
# Describe what our function does
sub reKeyTemplateAttachments {
my $session = shift;
print "\tChanging the key structure for the template attachments table... " unless $quiet;
# and here's our code
$session->db->write('ALTER TABLE template_attachments ADD COLUMN attachId CHAR(22) BINARY NOT NULL');
my $rh = $session->db->read('select url, templateId, revisionDate from template_attachments');
my $wh = $session->db->prepare('update template_attachments set attachId=? where url=? and templateId=? and revisionDate=?');
while (my @key = $rh->array) {
$wh->execute([$session->id->generate, @key ]);
}
$rh->finish;
$wh->finish;
$session->db->write('ALTER TABLE template_attachments DROP PRIMARY KEY');
$session->db->write('ALTER TABLE template_attachments ADD PRIMARY KEY (attachId)');
print "DONE!\n" unless $quiet;
}
#sub exampleFunction {
# my $session = shift;
# print "\tWe're doing some stuff here that you should know about... " unless $quiet;