Skip to content

Commit

Permalink
Add a workaround for the migration of the spider data
Browse files Browse the repository at this point in the history
Fixes #5941
  • Loading branch information
dtdesign committed Jun 22, 2024
1 parent d9b201f commit 00c2330
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,20 @@
*/

use wcf\system\database\table\column\IntDatabaseTableColumn;
use wcf\system\database\table\DatabaseTableChangeProcessor;
use wcf\system\database\table\index\DatabaseTableForeignKey;
use wcf\system\database\table\index\DatabaseTableIndex;
use wcf\system\database\table\PartialDatabaseTable;
use wcf\system\WCF;

return [
$tableNames = WCF::getDB()->getEditor()->getTableNames();
if (!\in_array('wcf' . WCF_N . '_spider', $tableNames)) {
// The table `wcf1_spider` will be removed by a database PIP that is
// executed after this script.
return;
}

$tables = [
PartialDatabaseTable::create('wcf1_session')
->columns([
IntDatabaseTableColumn::create('spiderID')
Expand All @@ -27,6 +36,9 @@
->drop(),
])
->foreignKeys([
// This foreign key definition fails to validate when the table
// `wcf1_spider` no longer exists, despite it being scheduled for
// removal.
DatabaseTableForeignKey::create()
->columns(['spiderID'])
->referencedTable('wcf1_spider')
Expand All @@ -35,3 +47,11 @@
->drop(),
]),
];

(new DatabaseTableChangeProcessor(
/** @var ScriptPackageInstallationPlugin $this */
$this->installation->getPackage(),
$tables,
WCF::getDB()->getEditor()
)
)->process();

0 comments on commit 00c2330

Please sign in to comment.