Bug 25655: DB changes

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2023-01-16 21:09:05 +01:00 committed by Tomas Cohen Arazi
parent 3bf4addb24
commit ed78a5bc57
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,26 @@
use Modern::Perl;
return {
bug_number => "25655",
description => "Store actual cost in foreign currency and currency from the invoices",
up => sub {
my ($args) = @_;
my ($dbh, $out) = @$args{qw(dbh out)};
unless ( column_exists('aqorders', 'invoice_unitprice') ) {
$dbh->do(q{
ALTER TABLE aqorders
ADD COLUMN invoice_unitprice decimal(28,6) DEFAULT NULL COMMENT 'the unit price in foreign currency' AFTER estimated_delivery_date
});
}
say $out "Added column 'aqorders.invoice_unitprice'";
unless ( column_exists('aqorders', 'invoice_currency') ) {
$dbh->do(q{
ALTER TABLE aqorders
ADD COLUMN invoice_currency varchar(10) DEFAULT NULL COMMENT 'the currency of the invoice_unitprice' AFTER invoice_unitprice,
ADD CONSTRAINT `aqorders_invoice_currency` FOREIGN KEY (`invoice_currency`) REFERENCES `currency` (`currency`) ON DELETE SET NULL ON UPDATE SET NULL
});
}
say $out "Added column 'aqorders.invoice_currency'";
},
};

View File

@ -690,6 +690,8 @@ CREATE TABLE `aqorders` (
`suppliers_reference_qualifier` varchar(3) DEFAULT NULL COMMENT 'Type of number above usually ''QLI''',
`suppliers_report` mediumtext DEFAULT NULL COMMENT 'reports received from suppliers',
`estimated_delivery_date` date DEFAULT NULL COMMENT 'Estimated delivery date',
`invoice_unitprice` decimal(28,6) DEFAULT NULL COMMENT 'the unit price in foreign currency',
`invoice_currency` varchar(10) DEFAULT NULL COMMENT 'the currency of the invoice_unitprice',
PRIMARY KEY (`ordernumber`),
KEY `basketno` (`basketno`),
KEY `biblionumber` (`biblionumber`),
@ -703,6 +705,7 @@ CREATE TABLE `aqorders` (
CONSTRAINT `aqorders_budget_id_fk` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `aqorders_created_by` FOREIGN KEY (`created_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `aqorders_currency` FOREIGN KEY (`currency`) REFERENCES `currency` (`currency`) ON DELETE SET NULL ON UPDATE SET NULL,
CONSTRAINT `aqorders_invoice_currency` FOREIGN KEY (`invoice_currency`) REFERENCES `currency` (`currency`) ON DELETE SET NULL ON UPDATE SET NULL,
CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `aqorders_ibfk_3` FOREIGN KEY (`invoiceid`) REFERENCES `aqinvoices` (`invoiceid`) ON DELETE SET NULL ON UPDATE CASCADE,