|
Lines 7207-7212
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
Link Here
|
| 7207 |
ADD CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE |
7207 |
ADD CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE |
| 7208 |
|); |
7208 |
|); |
| 7209 |
|
7209 |
|
|
|
7210 |
# Set firstacquidate if not already set (firstacquidate is now mandatory) |
| 7211 |
my $get_first_planneddate_sth = $dbh->prepare(qq| |
| 7212 |
SELECT planneddate |
| 7213 |
FROM serial |
| 7214 |
WHERE subscriptionid = ? |
| 7215 |
ORDER BY serialid |
| 7216 |
LIMIT 1 |
| 7217 |
|); |
| 7218 |
my $update_firstacquidate_sth = $dbh->prepare(qq| |
| 7219 |
UPDATE subscription |
| 7220 |
SET firstacquidate = ? |
| 7221 |
WHERE subscriptionid = ? |
| 7222 |
|); |
| 7223 |
my $get_subscriptions_sth = $dbh->prepare(qq| |
| 7224 |
SELECT subscriptionid, startdate |
| 7225 |
FROM subscription |
| 7226 |
WHERE firstacquidate IS NULL |
| 7227 |
OR firstacquidate = '0000-00-00' |
| 7228 |
|); |
| 7229 |
$get_subscriptions_sth->execute; |
| 7230 |
while ( my ($subscriptionid, $startdate) = $get_subscriptions_sth->fetchrow ) { |
| 7231 |
# Try to get the planned date of the first serial |
| 7232 |
$get_first_planneddate_sth->execute($subscriptionid); |
| 7233 |
my ($first_planneddate) = $get_first_planneddate_sth->fetchrow; |
| 7234 |
if ($first_planneddate and $first_planneddate =~ /^\d{4}-\d{2}-\d{2}$/) { |
| 7235 |
$update_firstacquidate_sth->execute($first_planneddate, $subscriptionid); |
| 7236 |
} else { |
| 7237 |
# Defaults to subscription start date |
| 7238 |
$update_firstacquidate_sth->execute($startdate, $subscriptionid); |
| 7239 |
} |
| 7240 |
} |
| 7241 |
|
| 7210 |
print "Upgrade to $DBversion done (Add subscription_frequencies and subscription_numberpatterns tables)\n"; |
7242 |
print "Upgrade to $DBversion done (Add subscription_frequencies and subscription_numberpatterns tables)\n"; |
| 7211 |
SetVersion($DBversion); |
7243 |
SetVersion($DBversion); |
| 7212 |
} |
7244 |
} |