Browse Source

Bug 14187: (QA followup) Properly check DB structure before altering it

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
17.05.x
Tomás Cohen Arazi 7 years ago
committed by Kyle M Hall
parent
commit
ac3e4ce671
  1. 17
      installer/data/mysql/atomicupdate/14187.perl

17
installer/data/mysql/atomicupdate/14187.perl

@ -1,8 +1,15 @@
$DBversion = 'XXX'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
$dbh->do("ALTER TABLE branchtransfers ADD COLUMN branchtransfer_id int(12) NOT NULL auto_increment FIRST, ADD CONSTRAINT PRIMARY KEY (branchtransfer_id);");
$DBversion = '16.12.00.XXX';
if ( CheckVersion($DBversion) ) {
unless (column_exists( 'branchtransfers', 'branchtransfer_id' )
and index_exists( 'branchtransfers', 'PRIMARY' ) )
{
$dbh->do(
"ALTER TABLE branchtransfers
ADD COLUMN branchtransfer_id int(12) NOT NULL auto_increment FIRST, ADD CONSTRAINT PRIMARY KEY (branchtransfer_id);"
);
}
# Always end with this (adjust the bug info)
SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 14187 - branchtransfer needs a primary key (id) for DBIx and common sense.)\n";
SetVersion($DBversion);
print "Upgrade to $DBversion done (Bug 14187: branchtransfer needs a primary key (id) for DBIx and common sense.)\n";
}

Loading…
Cancel
Save