Lines 2-13
$DBversion = 'XXX'; # will be replaced by the RM
Link Here
|
2 |
if( CheckVersion( $DBversion ) ) { |
2 |
if( CheckVersion( $DBversion ) ) { |
3 |
|
3 |
|
4 |
$dbh->do(q| |
4 |
$dbh->do(q| |
|
|
5 |
UPDATE |
6 |
serial |
7 |
SET |
8 |
planneddate = NULL |
9 |
WHERE |
10 |
planneddate = '0000-00-00' |
11 |
|); |
12 |
|
13 |
$dbh->do(q| |
14 |
UPDATE |
15 |
serial |
16 |
SET |
17 |
publisheddate = NULL |
18 |
WHERE |
19 |
publisheddate = '0000-00-00' |
20 |
|); |
21 |
|
22 |
$dbh->do(q| |
23 |
UPDATE |
24 |
serial |
25 |
SET |
26 |
claimdate = NULL |
27 |
WHERE |
28 |
claimdate = '0000-00-00' |
29 |
|); |
30 |
|
31 |
$dbh->do(q| |
5 |
ALTER TABLE serial |
32 |
ALTER TABLE serial |
6 |
MODIFY COLUMN biblionumber INT(11) NOT NULL |
33 |
MODIFY COLUMN biblionumber INT(11) NOT NULL |
7 |
|); |
34 |
|); |
8 |
|
35 |
|
9 |
unless ( foreign_key_exists( 'serial', 'serial_ibfk_1' ) ) { |
36 |
unless ( foreign_key_exists( 'serial', 'serial_ibfk_1' ) ) { |
10 |
$dbh->do(q| |
37 |
$dbh->do(q| |
|
|
38 |
DELETE FROM serial WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio) |
39 |
|); |
40 |
$dbh->do(q| |
11 |
ALTER TABLE serial |
41 |
ALTER TABLE serial |
12 |
ADD CONSTRAINT serial_ibfk_1 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE |
42 |
ADD CONSTRAINT serial_ibfk_1 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE |
13 |
|); |
43 |
|); |
Lines 20-25
if( CheckVersion( $DBversion ) ) {
Link Here
|
20 |
|
50 |
|
21 |
unless ( foreign_key_exists( 'serial', 'serial_ibfk_2' ) ) { |
51 |
unless ( foreign_key_exists( 'serial', 'serial_ibfk_2' ) ) { |
22 |
$dbh->do(q| |
52 |
$dbh->do(q| |
|
|
53 |
DELETE FROM serial WHERE subscriptionid NOT IN (SELECT subscriptionid FROM subscription) |
54 |
|); |
55 |
$dbh->do(q| |
23 |
ALTER TABLE serial |
56 |
ALTER TABLE serial |
24 |
ADD CONSTRAINT serial_ibfk_2 FOREIGN KEY (subscriptionid) REFERENCES subscription (subscriptionid) ON DELETE CASCADE ON UPDATE CASCADE |
57 |
ADD CONSTRAINT serial_ibfk_2 FOREIGN KEY (subscriptionid) REFERENCES subscription (subscriptionid) ON DELETE CASCADE ON UPDATE CASCADE |
25 |
|); |
58 |
|); |
Lines 33-38
if( CheckVersion( $DBversion ) ) {
Link Here
|
33 |
|
66 |
|
34 |
unless ( foreign_key_exists( 'subscriptionhistory', 'subscription_history_ibfk_1' ) ) { |
67 |
unless ( foreign_key_exists( 'subscriptionhistory', 'subscription_history_ibfk_1' ) ) { |
35 |
$dbh->do(q| |
68 |
$dbh->do(q| |
|
|
69 |
DELETE FROM subscriptionhistory WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio) |
70 |
|); |
71 |
$dbh->do(q| |
36 |
ALTER TABLE subscriptionhistory |
72 |
ALTER TABLE subscriptionhistory |
37 |
ADD CONSTRAINT subscription_history_ibfk_1 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE |
73 |
ADD CONSTRAINT subscription_history_ibfk_1 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE |
38 |
|); |
74 |
|); |
Lines 40-45
if( CheckVersion( $DBversion ) ) {
Link Here
|
40 |
|
76 |
|
41 |
unless ( foreign_key_exists( 'subscriptionhistory', 'subscription_history_ibfk_2' ) ) { |
77 |
unless ( foreign_key_exists( 'subscriptionhistory', 'subscription_history_ibfk_2' ) ) { |
42 |
$dbh->do(q| |
78 |
$dbh->do(q| |
|
|
79 |
DELETE FROM subscriptionhistory WHERE subscriptionid NOT IN (SELECT subscriptionid FROM subscription) |
80 |
|); |
81 |
$dbh->do(q| |
43 |
ALTER TABLE subscriptionhistory |
82 |
ALTER TABLE subscriptionhistory |
44 |
ADD CONSTRAINT subscription_history_ibfk_2 FOREIGN KEY (subscriptionid) REFERENCES subscription (subscriptionid) ON DELETE CASCADE ON UPDATE CASCADE |
83 |
ADD CONSTRAINT subscription_history_ibfk_2 FOREIGN KEY (subscriptionid) REFERENCES subscription (subscriptionid) ON DELETE CASCADE ON UPDATE CASCADE |
45 |
|); |
84 |
|); |
Lines 52-57
if( CheckVersion( $DBversion ) ) {
Link Here
|
52 |
|
91 |
|
53 |
unless ( foreign_key_exists( 'subscription', 'subscription_ibfk_3' ) ) { |
92 |
unless ( foreign_key_exists( 'subscription', 'subscription_ibfk_3' ) ) { |
54 |
$dbh->do(q| |
93 |
$dbh->do(q| |
|
|
94 |
DELETE FROM subscription WHERE biblionumber NOT IN (SELECT biblionumber FROM biblio) |
95 |
|); |
96 |
$dbh->do(q| |
55 |
ALTER TABLE subscription |
97 |
ALTER TABLE subscription |
56 |
ADD CONSTRAINT subscription_ibfk_3 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE |
98 |
ADD CONSTRAINT subscription_ibfk_3 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE |
57 |
|); |
99 |
|); |
58 |
- |
|
|