Lines 6988-6993
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
Link Here
|
6988 |
ADD CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE |
6988 |
ADD CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE |
6989 |
|); |
6989 |
|); |
6990 |
|
6990 |
|
|
|
6991 |
# Set firstacquidate if not already set (firstacquidate is now mandatory) |
6992 |
my $get_first_planneddate_sth = $dbh->prepare(qq| |
6993 |
SELECT planneddate |
6994 |
FROM serial |
6995 |
WHERE subscriptionid = ? |
6996 |
ORDER BY serialid |
6997 |
LIMIT 1 |
6998 |
|); |
6999 |
my $update_firstacquidate_sth = $dbh->prepare(qq| |
7000 |
UPDATE subscription |
7001 |
SET firstacquidate = ? |
7002 |
WHERE subscriptionid = ? |
7003 |
|); |
7004 |
my $get_subscriptions_sth = $dbh->prepare(qq| |
7005 |
SELECT subscriptionid, startdate |
7006 |
FROM subscription |
7007 |
WHERE firstacquidate IS NULL |
7008 |
OR firstacquidate = '0000-00-00' |
7009 |
|); |
7010 |
$get_subscriptions_sth->execute; |
7011 |
while ( my ($subscriptionid, $startdate) = $get_subscriptions_sth->fetchrow ) { |
7012 |
# Try to get the planned date of the first serial |
7013 |
$get_first_planneddate_sth->execute($subscriptionid); |
7014 |
my ($first_planneddate) = $get_first_planneddate_sth->fetchrow; |
7015 |
if ($first_planneddate and $first_planneddate =~ /^\d{4}-\d{2}-\d{2}$/) { |
7016 |
$update_firstacquidate_sth->execute($first_planneddate, $subscriptionid); |
7017 |
} else { |
7018 |
# Defaults to subscription start date |
7019 |
$update_firstacquidate_sth->execute($startdate, $subscriptionid); |
7020 |
} |
7021 |
} |
7022 |
|
6991 |
print "Upgrade to $DBversion done (Add subscription_frequencies and subscription_numberpatterns tables)\n"; |
7023 |
print "Upgrade to $DBversion done (Add subscription_frequencies and subscription_numberpatterns tables)\n"; |
6992 |
SetVersion($DBversion); |
7024 |
SetVersion($DBversion); |
6993 |
} |
7025 |
} |