Bug 24289: DBRev 19.05.07.004

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Lucas Gass 2020-02-13 21:09:05 +00:00
parent ad75bdf50e
commit f8c6d6fdd7
3 changed files with 33 additions and 32 deletions

View File

@ -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 = "19.05.07.003";
$VERSION = "19.05.07.004";
sub version {
return $VERSION;

View File

@ -1,31 +0,0 @@
$DBversion = 'XXX'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
if( !foreign_key_exists( 'repeatable_holidays', 'repeatable_holidays_ibfk_1' ) ) {
$dbh->do(q|
DELETE h
FROM repeatable_holidays h
LEFT JOIN branches b ON h.branchcode=b.branchcode
WHERE b.branchcode IS NULL;
|);
$dbh->do(q|
ALTER TABLE repeatable_holidays
ADD FOREIGN KEY repeatable_holidays_ibfk_1 (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE
|);
}
if( !foreign_key_exists( 'special_holidays', 'special_holidays_ibfk_1' ) ) {
$dbh->do(q|
DELETE h
FROM special_holidays h
LEFT JOIN branches b ON h.branchcode=b.branchcode
WHERE b.branchcode IS NULL;
|);
$dbh->do(q|
ALTER TABLE special_holidays
ADD FOREIGN KEY special_holidays_ibfk_1 (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE
|);
}
SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 24289 - Adding foreign keys on *_holidays.branchcode tables)\n";
}

View File

@ -18915,6 +18915,38 @@ if( CheckVersion( $DBversion ) ) {
print "Upgrade to $DBversion done (Bug 24206 - Update OpacSearchForTitleIn system preference)\n";
}
$DBversion = '19.05.07.004'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
if( !foreign_key_exists( 'repeatable_holidays', 'repeatable_holidays_ibfk_1' ) ) {
$dbh->do(q|
DELETE h
FROM repeatable_holidays h
LEFT JOIN branches b ON h.branchcode=b.branchcode
WHERE b.branchcode IS NULL;
|);
$dbh->do(q|
ALTER TABLE repeatable_holidays
ADD FOREIGN KEY repeatable_holidays_ibfk_1 (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE
|);
}
if( !foreign_key_exists( 'special_holidays', 'special_holidays_ibfk_1' ) ) {
$dbh->do(q|
DELETE h
FROM special_holidays h
LEFT JOIN branches b ON h.branchcode=b.branchcode
WHERE b.branchcode IS NULL;
|);
$dbh->do(q|
ALTER TABLE special_holidays
ADD FOREIGN KEY special_holidays_ibfk_1 (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE
|);
}
SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 24289 - Adding foreign keys on *_holidays.branchcode tables)\n";
}
# SEE bug 13068
# if there is anything in the atomicupdate, read and execute it.