From 66383c70424f07690e921a562b118b0fd2328352 Mon Sep 17 00:00:00 2001 From: Amit Gupta Date: Mon, 10 Jun 2013 13:34:41 +0530 Subject: [PATCH 2/4] Bug 10412 - Adding new table aqcreditnotes. --- installer/data/mysql/kohastructure.sql | 21 +++++++++++++++++++++ installer/data/mysql/updatedatabase.pl | 20 ++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index ca2f2b2..2a53385 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2961,6 +2961,27 @@ CREATE TABLE aqinvoices ( -- +-- 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; + +-- -- Table structure for table `fieldmapping` -- diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 648e161..30f9c70 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6990,6 +6990,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.7.9.5