DBRev Bug 15084 - Move the currency related code to
Koha::Acquisition::Currenc[y|ies]
This commit is contained in:
parent
65c4694b7a
commit
e88457a9fa
3 changed files with 24 additions and 9 deletions
2
Koha.pm
2
Koha.pm
|
@ -29,7 +29,7 @@ use vars qw{ $VERSION };
|
|||
# - #4 : the developer version. The 4th number is the database subversion.
|
||||
# used by developers when the database changes. updatedatabase take care of the changes itself
|
||||
# and is automatically called by Auth.pm when needed.
|
||||
$VERSION = "3.23.00.036";
|
||||
$VERSION = "3.23.00.037";
|
||||
|
||||
sub version {
|
||||
return $VERSION;
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
-- Add the new currency.archived column
|
||||
alter table currency add column archived tinyint(1) default 0;
|
||||
-- Set currency=NULL if empty (just in case)
|
||||
update aqorders set currency=NULL where currency="";
|
||||
-- Insert the missing currency and mark them as archived before adding the FK
|
||||
insert into currency(currency, archived) select distinct currency, 1 from aqorders where currency not in (select currency from currency);
|
||||
-- And finally add the FK
|
||||
alter table aqorders add foreign key (currency) references currency(currency) on delete set null on update set null;
|
|
@ -11973,6 +11973,29 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
|
|||
SetVersion($DBversion);
|
||||
}
|
||||
|
||||
$DBversion = "3.23.00.037";
|
||||
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
|
||||
## Add the new currency.archived column
|
||||
$dbh->do(q{
|
||||
ALTER TABLE currency ADD column archived tinyint(1) DEFAULT 0;
|
||||
});
|
||||
## Set currency=NULL if empty (just in case)
|
||||
$dbh->do(q{
|
||||
UPDATE aqorders SET currency=NULL WHERE currency="";
|
||||
});
|
||||
## Insert the missing currency and mark them as archived before adding the FK
|
||||
$dbh->do(q{
|
||||
INSERT INTO currency(currency, archived) SELECT distinct currency, 1 FROM aqorders WHERE currency NOT IN (SELECT currency FROM currency);
|
||||
});
|
||||
## And finally add the FK
|
||||
$dbh->do(q{
|
||||
ALTER TABLE aqorders ADD FOREIGN KEY (currency) REFERENCES currency(currency) ON DELETE SET NULL ON UPDATE SET null;
|
||||
});
|
||||
|
||||
print "Upgrade to $DBversion done (Bug 15084 - Move the currency related code to Koha::Acquisition::Currenc[y|ies])\n";
|
||||
SetVersion($DBversion);
|
||||
}
|
||||
|
||||
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
|
||||
# SEE bug 13068
|
||||
# if there is anything in the atomicupdate, read and execute it.
|
||||
|
|
Loading…
Reference in a new issue