From ff443ed3c591920d676c8c568c5c675b658495c8 Mon Sep 17 00:00:00 2001 From: Amit Gupta Date: Fri, 18 Oct 2013 20:31:50 +0530 Subject: [PATCH] Bug 10412 - Adding new table aqcreditnotes. --- installer/data/mysql/kohastructure.sql | 22 ++++++++++++++++++++++ installer/data/mysql/updatedatabase.pl | 20 ++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index a6a779e..2bc13ba 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -3313,6 +3313,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 3d2ca44..6d5ac4a 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7595,6 +7595,26 @@ 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 -- 1.8.4.rc3