From 0f6c885ddad8169c042f17d631dfb41bb020b97a Mon Sep 17 00:00:00 2001 From: Amit Gupta Date: Fri, 18 Oct 2013 20:31:50 +0530 Subject: [PATCH 2/2] Bug 10412 - Adding new table aqcreditnotes. --- installer/data/mysql/kohastructure.sql | 22 ++++++++++++++++++++++ installer/data/mysql/updatedatabase.pl | 21 +++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index e1e3e96..2206512 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -3276,6 +3276,28 @@ ALTER TABLE `patron_list_patrons` ADD CONSTRAINT patron_list_patrons_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE; +-- +-- Table structure for table 'aqcreditnotes' +-- + +DROP TABLE IF EXISTS aqcreditnotes; +CREATE TABLE aqcreditnotes ( + `creditnote_id` int(11) NOT NULL AUTO_INCREMENT, -- ID of the creditnote, primary key + `booksellerid` int(11) NOT NULL, -- foreign key to aqbooksellers + `invoiceid` int(11) NOT NULL, -- foreign key to aqinvoices + `vendorrefid` varchar(20) NOT NULL, -- Vendorreferenceid + `budget_id` int(11) NOT NULL, -- foreign key to aqbudgets + `amountcredit` decimal(28,6) default NULL, -- amountcredit cost + `creditdate` date default NULL, -- date of amountcredit + `notes` mediumtext, -- notes of amountcredit + `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time this record was last touched + PRIMARY KEY (creditnote_id), + CONSTRAINT aqcreditnotes_fk_aqbooksellerid FOREIGN KEY (booksellerid) REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT aqcreditnotes_fk_invoiceid FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT aqcreditnotes_fk_budget_id FOREIGN KEY (budget_id) REFERENCES aqbudgets (budget_id) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 9f57eff..2593b8a 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7306,6 +7306,27 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.13.00.XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("CREATE TABLE aqcreditnotes ( + `creditnote_id` int(11) NOT NULL AUTO_INCREMENT, + `booksellerid` int(11) NOT NULL, + `invoiceid` int(11) NOT NULL, + `vendorrefid` varchar(80) NOT NULL, + `budget_id` int(11) NOT NULL, + `amountcredit` decimal(28,6) default NULL, + `creditdate` date default NULL, + `notes` mediumtext, + `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + PRIMARY KEY (creditnote_id), + CONSTRAINT aqcreditnotes_fk_aqbooksellerid FOREIGN KEY (booksellerid) REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT aqcreditnotes_fk_invoiceid FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT aqcreditnotes_fk_budget_id FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8"); + print "Upgrade to $DBversion done (Added new table aqcreditnotes)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) -- 1.7.9.5