Lines 7152-7157
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
Link Here
|
7152 |
ADD CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE |
7152 |
ADD CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE |
7153 |
|); |
7153 |
|); |
7154 |
|
7154 |
|
|
|
7155 |
# Set firstacquidate if not already set (firstacquidate is now mandatory) |
7156 |
my $get_first_planneddate_sth = $dbh->prepare(qq| |
7157 |
SELECT planneddate |
7158 |
FROM serial |
7159 |
WHERE subscriptionid = ? |
7160 |
ORDER BY serialid |
7161 |
LIMIT 1 |
7162 |
|); |
7163 |
my $update_firstacquidate_sth = $dbh->prepare(qq| |
7164 |
UPDATE subscription |
7165 |
SET firstacquidate = ? |
7166 |
WHERE subscriptionid = ? |
7167 |
|); |
7168 |
my $get_subscriptions_sth = $dbh->prepare(qq| |
7169 |
SELECT subscriptionid, startdate |
7170 |
FROM subscription |
7171 |
WHERE firstacquidate IS NULL |
7172 |
OR firstacquidate = '0000-00-00' |
7173 |
|); |
7174 |
$get_subscriptions_sth->execute; |
7175 |
while ( my ($subscriptionid, $startdate) = $get_subscriptions_sth->fetchrow ) { |
7176 |
# Try to get the planned date of the first serial |
7177 |
$get_first_planneddate_sth->execute($subscriptionid); |
7178 |
my ($first_planneddate) = $get_first_planneddate_sth->fetchrow; |
7179 |
if ($first_planneddate and $first_planneddate =~ /^\d{4}-\d{2}-\d{2}$/) { |
7180 |
$update_firstacquidate_sth->execute($first_planneddate, $subscriptionid); |
7181 |
} else { |
7182 |
# Defaults to subscription start date |
7183 |
$update_firstacquidate_sth->execute($startdate, $subscriptionid); |
7184 |
} |
7185 |
} |
7186 |
|
7155 |
print "Upgrade to $DBversion done (Add subscription_frequencies and subscription_numberpatterns tables)\n"; |
7187 |
print "Upgrade to $DBversion done (Add subscription_frequencies and subscription_numberpatterns tables)\n"; |
7156 |
SetVersion($DBversion); |
7188 |
SetVersion($DBversion); |
7157 |
} |
7189 |
} |