From 84925094199906e47d3d482a17d6b55d31ec06a2 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 1 Feb 2017 15:53:06 +0100 Subject: [PATCH] Bug 14224: Check if the columns do not exist before creating them Signed-off-by: Jonathan Druart --- .../atomicupdate/bug_14224-add_new_issue_columns.perl | 18 ++++++++++++++++++ .../atomicupdate/bug_14224-add_new_issue_columns.sql | 4 ---- 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_14224-add_new_issue_columns.perl delete mode 100644 installer/data/mysql/atomicupdate/bug_14224-add_new_issue_columns.sql diff --git a/installer/data/mysql/atomicupdate/bug_14224-add_new_issue_columns.perl b/installer/data/mysql/atomicupdate/bug_14224-add_new_issue_columns.perl new file mode 100644 index 0000000..3f9d1dc --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_14224-add_new_issue_columns.perl @@ -0,0 +1,18 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + unless( column_exists( 'issues', 'note' ) ) { + $dbh->do(q|ALTER IGNORE TABLE issues ADD note mediumtext default NULL AFTER onsite_checkout|); + } + unless( column_exists( 'issues', 'notedate' ) ) { + $dbh->do(q|ALTER IGNORE TABLE issues ADD notedate datetime default NULL AFTER note|); + } + unless( column_exists( 'old_issues', 'note' ) ) { + $dbh->do(q|ALTER IGNORE TABLE old_issues ADD note mediumtext default NULL AFTER onsite_checkout|); + } + unless( column_exists( 'old_issues', 'notedate' ) ) { + $dbh->do(q|ALTER IGNORE 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"; +} diff --git a/installer/data/mysql/atomicupdate/bug_14224-add_new_issue_columns.sql b/installer/data/mysql/atomicupdate/bug_14224-add_new_issue_columns.sql deleted file mode 100644 index 6ed41dc..0000000 --- a/installer/data/mysql/atomicupdate/bug_14224-add_new_issue_columns.sql +++ /dev/null @@ -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`; -- 2.1.4