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>
This commit is contained in:
Tomas Cohen Arazi 2017-01-12 12:42:05 -03:00 committed by Kyle M Hall
parent 292b9df914
commit ac3e4ce671
1 changed files with 12 additions and 5 deletions

View File

@ -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";
}