Bug 14224: Check if the columns do not exist before creating them

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2017-02-01 15:53:06 +01:00 committed by Kyle M Hall
parent e54152a90b
commit 0fa07cce32
2 changed files with 18 additions and 4 deletions

View file

@ -0,0 +1,18 @@
$DBversion = 'XXX';
if( CheckVersion( $DBversion ) ) {
unless( column_exists( 'issues', 'note' ) ) {
$dbh->do(q|ALTER TABLE issues ADD note mediumtext default NULL AFTER onsite_checkout|);
}
unless( column_exists( 'issues', 'notedate' ) ) {
$dbh->do(q|ALTER TABLE issues ADD notedate datetime default NULL AFTER note|);
}
unless( column_exists( 'old_issues', 'note' ) ) {
$dbh->do(q|ALTER TABLE old_issues ADD note mediumtext default NULL AFTER onsite_checkout|);
}
unless( column_exists( 'old_issues', 'notedate' ) ) {
$dbh->do(q|ALTER TABLE old_issues ADD notedate datetime default NULL AFTER note|);
}
SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 14224: Add column issues.note and issues.notedate)\n";
}

View file

@ -1,4 +0,0 @@
ALTER IGNORE TABLE issues ADD `note` mediumtext default NULL AFTER `onsite_checkout`;
ALTER IGNORE TABLE issues ADD `notedate` datetime default NULL AFTER `note`;
ALTER IGNORE TABLE old_issues ADD `note` mediumtext default NULL AFTER `onsite_checkout`;
ALTER IGNORE TABLE old_issues ADD `notedate` datetime default NULL AFTER `note`;