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