Lines 6917-6922
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
Link Here
|
6917 |
ADD CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE |
6917 |
ADD CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE |
6918 |
|); |
6918 |
|); |
6919 |
|
6919 |
|
|
|
6920 |
# Set firstacquidate if not already set (firstacquidate is now mandatory) |
6921 |
my $get_first_planneddate_sth = $dbh->prepare(qq| |
6922 |
SELECT planneddate |
6923 |
FROM serial |
6924 |
WHERE subscriptionid = ? |
6925 |
ORDER BY serialid |
6926 |
LIMIT 1 |
6927 |
|); |
6928 |
my $update_firstacquidate_sth = $dbh->prepare(qq| |
6929 |
UPDATE subscription |
6930 |
SET firstacquidate = ? |
6931 |
WHERE subscriptionid = ? |
6932 |
|); |
6933 |
my $get_subscriptions_sth = $dbh->prepare(qq| |
6934 |
SELECT subscriptionid, startdate |
6935 |
FROM subscription |
6936 |
WHERE firstacquidate IS NULL |
6937 |
OR firstacquidate = '0000-00-00' |
6938 |
|); |
6939 |
$get_subscriptions_sth->execute; |
6940 |
while ( my ($subscriptionid, $startdate) = $get_subscriptions_sth->fetchrow ) { |
6941 |
# Try to get the planned date of the first serial |
6942 |
$get_first_planneddate_sth->execute($subscriptionid); |
6943 |
my ($first_planneddate) = $get_first_planneddate_sth->fetchrow; |
6944 |
if ($first_planneddate and $first_planneddate =~ /^\d{4}-\d{2}-\d{2}$/) { |
6945 |
$update_firstacquidate_sth->execute($first_planneddate, $subscriptionid); |
6946 |
} else { |
6947 |
# Defaults to subscription start date |
6948 |
$update_firstacquidate_sth->execute($startdate, $subscriptionid); |
6949 |
} |
6950 |
} |
6951 |
|
6920 |
print "Upgrade to $DBversion done (Add subscription_frequencies and subscription_numberpatterns tables)\n"; |
6952 |
print "Upgrade to $DBversion done (Add subscription_frequencies and subscription_numberpatterns tables)\n"; |
6921 |
SetVersion($DBversion); |
6953 |
SetVersion($DBversion); |
6922 |
} |
6954 |
} |