From b4c3f23c0bfe4d55fc3bd171585070c9420027b9 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 19 Dec 2013 17:51:34 -0500 Subject: [PATCH] Bug 7567 - Added branchcode to opac_news This patch merely adds branchcode varchar(10) DEFAULT NULL to the opac_news table. TEST PLAN --------- 1) backup your kohadata base if you care about the data. 2) use the koha database 3) describe opac_news; 4) show create table opac_news; -- No branchcode constraint will exist. 5) apply the patch 6) upgrade the database (either staff client or script) 7) use the koha database 8) describe opac_news; 9) show create table opac_news; -- The branchcode constraint should be listed. 10) drop that koha database 11) create the koha database 12) use the koha database 13) source ~/kohaclone/installer/data/mysql/kohastructure.sql -- there should be no errors in creating the database. 14) describe opac_news; 15) show create table opac_news; -- The branchcode constraint should be listed. 16) restore your koha database if you backed it up. Signed-off-by: Chris Cormack Signed-off-by: Jonathan Druart Signed-off-by: Galen Charlton --- installer/data/mysql/kohastructure.sql | 5 ++++- installer/data/mysql/updatedatabase.pl | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 3cf9c65e80..5facb65c13 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1642,13 +1642,16 @@ CREATE TABLE `old_reserves` ( -- this table holds all holds/reserves that have b DROP TABLE IF EXISTS `opac_news`; CREATE TABLE `opac_news` ( -- data from the news tool `idnew` int(10) unsigned NOT NULL auto_increment, -- unique identifier for the news article + `branchcode` varchar(10) default NULL, -- branch code users to create branch specific news, NULL is every branch. `title` varchar(250) NOT NULL default '', -- title of the news article `new` text NOT NULL, -- the body of your news article `lang` varchar(25) NOT NULL default '', -- location for the article (koha is the staff client, slip is the circulation receipt and language codes are for the opac) `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, -- pulibcation date and time `expirationdate` date default NULL, -- date the article is set to expire or no longer be visible `number` int(11) default NULL, -- the order in which this article appears in that specific location - PRIMARY KEY (`idnew`) + PRIMARY KEY (`idnew`), + CONSTRAINT opac_news_branchcode_ibfk FOREIGN KEY (branchcode) REFERENCES branches (branchcode) + ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 062ecc12e7..5e7bc270eb 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8083,6 +8083,21 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.15.00.XXX"; +if (CheckVersion($DBversion)) { + $dbh->do(q{ + ALTER TABLE opac_news ADD branchcode varchar(10) DEFAULT NULL + AFTER idnew, + ADD CONSTRAINT opac_news_branchcode_ibfk + FOREIGN KEY (branchcode) + REFERENCES branches (branchcode) + ON DELETE CASCADE ON UPDATE CASCADE; + }); + print "Upgrade to $DBversion done (Bug 7567: Add branchcode to opac_news)\n"; + SetVersion($DBversion); +} + + =head1 FUNCTIONS =head2 TableExists($table) -- 2.39.5