Index: trunk/phase3/maintenance/postgres/tables.sql |
— | — | @@ -288,7 +288,7 @@ |
289 | 289 | oi_deleted SMALLINT NOT NULL DEFAULT 0, |
290 | 290 | oi_sha1 TEXT NOT NULL DEFAULT '' |
291 | 291 | ); |
292 | | -ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascade FOREIGN KEY (oi_name) REFERENCES image(img_name) ON DELETE CASCADE ON UPDATE CASCADE; |
| 292 | +ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascaded FOREIGN KEY (oi_name) REFERENCES image(img_name) ON DELETE CASCADE ON UPDATE CASCADE; |
293 | 293 | CREATE INDEX oi_name_timestamp ON oldimage (oi_name,oi_timestamp); |
294 | 294 | CREATE INDEX oi_name_archive_name ON oldimage (oi_name,oi_archive_name); |
295 | 295 | CREATE INDEX oi_sha1 ON oldimage (oi_sha1); |
Index: trunk/phase3/maintenance/updaters.inc |
— | — | @@ -1739,14 +1739,20 @@ |
1740 | 1740 | dbsource(archive($nr[2])); |
1741 | 1741 | } |
1742 | 1742 | |
1743 | | - if ($wgDatabase->hasConstraint("oldimage_oi_name_fkey")) { |
1744 | | - wfOut( "Making foreign key on table \"oldimage\" (to image) a cascade delete\n" ); |
1745 | | - $wgDatabase->query( "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey" ); |
1746 | | - $wgDatabase->query( "ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascade ". |
1747 | | - "FOREIGN KEY (oi_name) REFERENCES image(img_name) ON DELETE CASCADE" ); |
| 1743 | + if ($wgDatabase->hasConstraint("oldimage_oi_name_fkey_cascaded")) { |
| 1744 | + wfOut( "... table \"oldimage\" has correct cascading delete/update foreign key to image\n" ); |
1748 | 1745 | } |
1749 | | - else |
1750 | | - wfOut( "... table \"oldimage\" has correct cascade delete foreign key to image\n" ); |
| 1746 | + else { |
| 1747 | + if ($wgDatabase->hasConstraint("oldimage_oi_name_fkey")) { |
| 1748 | + $wgDatabase->query( "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey" ); |
| 1749 | + } |
| 1750 | + if ($wgDatabase->hasConstraint("oldimage_oi_name_fkey_cascade")) { |
| 1751 | + $wgDatabase->query( "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey_cascade" ); |
| 1752 | + } |
| 1753 | + wfOut( "Making foreign key on table \"oldimage\" (to image) a cascade delete/update\n" ); |
| 1754 | + $wgDatabase->query( "ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascaded ". |
| 1755 | + "FOREIGN KEY (oi_name) REFERENCES image(img_name) ON DELETE CASCADE ON UPDATE CASCADE" ); |
| 1756 | + } |
1751 | 1757 | |
1752 | 1758 | if (!$wgDatabase->triggerExists("page", "page_deleted")) { |
1753 | 1759 | wfOut( "Adding function and trigger \"page_deleted\" to table \"page\"\n" ); |