Bug 14246: Add borrowernumber, altered SQL
authorMartin Persson <xarragon@gmail.com>
Wed, 27 May 2015 05:36:33 +0000 (07:36 +0200)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 27 Oct 2015 18:56:24 +0000 (15:56 -0300)
As suggested by kind reviewers, an AFTER statement was added to the atomic
upgrade script to ensure that the final field order is consistent is both
fresh and upgraded databases.

Also:
* UPDATE action changed to CASCADE to improve robustness.

Test plan:
* Apply first patch in this set.
* Apply this patch.
* Perform a database upgrade.
* Use mysql client to inspect field order.
  It should be identical to the kohastructure.sql order.

Sponsored-by: Halland County Library
Signed-off-by: Nick Clemens <nick@quecheelibrary.org>
Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
installer/data/mysql/atomicupdate/bug_14246-add_news_author.sql
installer/data/mysql/kohastructure.sql

index 1319d37..0a9362a 100644 (file)
@@ -1,2 +1,2 @@
-ALTER TABLE `opac_news` ADD `borrowernumber` INT(11) default NULL;
-ALTER TABLE `opac_news` ADD CONSTRAINT `borrowernumber_fk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers`(`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL;
+ALTER TABLE `opac_news` ADD `borrowernumber` int(11) AFTER `number` default NULL;
+ALTER TABLE `opac_news` ADD CONSTRAINT `borrowernumber_fk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers`(`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE;
index 9e31a35..3a30585 100644 (file)
@@ -1691,7 +1691,7 @@ CREATE TABLE `opac_news` ( -- data from the news tool
   `number` int(11) default NULL, -- the order in which this article appears in that specific location
   `borrowernumber` int(11) default NULL, -- The user who created the news article
   PRIMARY KEY  (`idnew`),
-  CONSTRAINT `borrowernumber_fk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL,
+  CONSTRAINT `borrowernumber_fk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
   CONSTRAINT opac_news_branchcode_ibfk FOREIGN KEY (branchcode) REFERENCES branches (branchcode)
     ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;