Add update instructions for index updates of `wcf1_tag_to_object`
authorMatthias Schmidt <gravatronics@live.com>
Fri, 29 Jan 2021 16:31:38 +0000 (17:31 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 29 Jan 2021 16:31:38 +0000 (17:31 +0100)
com.woltlab.wcf/package.xml
wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_wcf1_tag_to_object_step1.php [new file with mode: 0644]
wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_wcf1_tag_to_object_step2.php [new file with mode: 0644]
wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_wcf1_tag_to_object_step3.php [new file with mode: 0644]
wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_wcf1_tag_to_object_step4.php [new file with mode: 0644]

index 8ca2bdf808d846ba26dca8c1238ac915ac2247aa..9f9906faa2b7d8653e2fd9c13116a7d53133a528 100644 (file)
@@ -88,6 +88,12 @@ tar cvf com.woltlab.wcf/files_pre.tar -C wcfsetup/install/files/ \
                <!-- Non-critical database adjustments. -->
                <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_5.4_db.php</instruction>
                
+               <!-- Index updates for `wcf1_tag_to_object`. -->
+               <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_5.4_wcf1_tag_to_object_step1.php</instruction>
+               <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_5.4_wcf1_tag_to_object_step2.php</instruction>
+               <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_5.4_wcf1_tag_to_object_step3.php</instruction>
+               <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_5.4_wcf1_tag_to_object_step4.php</instruction>
+               
                <!-- Cleanup of the filesystem. -->
                <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_5.4_removeFiles.php</instruction>
                
diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_wcf1_tag_to_object_step1.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_wcf1_tag_to_object_step1.php
new file mode 100644 (file)
index 0000000..2cf146b
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+
+/**
+ * First step of the updates to the `wcf1_tag_to_object` table.
+ *
+ * The foreign keys needs to be dropped first because they required the dropped indices.
+ *
+ * @author  Matthias Schmidt
+ * @copyright   2001-2021 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core
+ */
+
+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\package\plugin\ScriptPackageInstallationPlugin;
+use wcf\system\WCF;
+
+$tables = [
+    PartialDatabaseTable::create('wcf1_tag_to_object')
+        ->foreignKeys([
+            DatabaseTableForeignKey::create()
+                ->columns(['tagID'])
+                ->referencedTable('wcf1_tag')
+                ->referencedColumns(['tagID'])
+                ->onDelete('CASCADE')
+                ->drop(),
+            DatabaseTableForeignKey::create()
+                ->columns(['languageID'])
+                ->referencedTable('wcf1_language')
+                ->referencedColumns(['languageID'])
+                ->onDelete('CASCADE')
+                ->drop(),
+            DatabaseTableForeignKey::create()
+                ->columns(['objectTypeID'])
+                ->referencedTable('wcf1_object_type')
+                ->referencedColumns(['objectTypeID'])
+                ->onDelete('CASCADE')
+                ->drop(),
+        ])
+        ->indices([
+            DatabaseTableIndex::create()
+                ->columns(['objectTypeID', 'languageID', 'objectID', 'tagID'])
+                ->type(DatabaseTableIndex::UNIQUE_TYPE)
+                ->drop(),
+            DatabaseTableIndex::create()
+                ->columns(['tagID', 'objectTypeID'])
+                ->drop(),
+        ]),
+];
+
+(new DatabaseTableChangeProcessor(
+    /** @var ScriptPackageInstallationPlugin $this */
+    $this->installation->getPackage(),
+    $tables,
+    WCF::getDB()->getEditor()
+))->process();
diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_wcf1_tag_to_object_step2.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_wcf1_tag_to_object_step2.php
new file mode 100644 (file)
index 0000000..2e5c31b
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * Second step of the updates to the `wcf1_tag_to_object` table.
+ *
+ * @author  Matthias Schmidt
+ * @copyright   2001-2021 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core
+ */
+
+use wcf\system\database\table\DatabaseTableChangeProcessor;
+use wcf\system\database\table\index\DatabaseTableIndex;
+use wcf\system\database\table\PartialDatabaseTable;
+use wcf\system\package\plugin\ScriptPackageInstallationPlugin;
+use wcf\system\WCF;
+
+$tables = [
+    PartialDatabaseTable::create('wcf1_tag_to_object')
+        ->indices([
+            DatabaseTableIndex::create()
+                ->columns(['objectTypeID', 'languageID', 'tagID'])
+                ->drop(),
+        ]),
+];
+
+(new DatabaseTableChangeProcessor(
+    /** @var ScriptPackageInstallationPlugin $this */
+    $this->installation->getPackage(),
+    $tables,
+    WCF::getDB()->getEditor()
+))->process();
diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_wcf1_tag_to_object_step3.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_wcf1_tag_to_object_step3.php
new file mode 100644 (file)
index 0000000..742554f
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * Third step of the updates to the `wcf1_tag_to_object` table.
+ *
+ * @author  Matthias Schmidt
+ * @copyright   2001-2021 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core
+ */
+
+use wcf\system\database\table\DatabaseTableChangeProcessor;
+use wcf\system\database\table\index\DatabaseTableForeignKey;
+use wcf\system\database\table\index\DatabaseTablePrimaryIndex;
+use wcf\system\database\table\PartialDatabaseTable;
+use wcf\system\package\plugin\ScriptPackageInstallationPlugin;
+use wcf\system\WCF;
+
+$tables = [
+    PartialDatabaseTable::create('wcf1_tag_to_object')
+        ->foreignKeys([
+            DatabaseTableForeignKey::create()
+                ->columns(['tagID'])
+                ->referencedTable('wcf1_tag')
+                ->referencedColumns(['tagID'])
+                ->onDelete('CASCADE'),
+            DatabaseTableForeignKey::create()
+                ->columns(['languageID'])
+                ->referencedTable('wcf1_language')
+                ->referencedColumns(['languageID'])
+                ->onDelete('CASCADE'),
+            DatabaseTableForeignKey::create()
+                ->columns(['objectTypeID'])
+                ->referencedTable('wcf1_object_type')
+                ->referencedColumns(['objectTypeID'])
+                ->onDelete('CASCADE'),
+        ])
+        ->indices([
+            DatabaseTablePrimaryIndex::create()
+                ->columns(['objectTypeID', 'objectID', 'tagID']),
+        ]),
+];
+
+(new DatabaseTableChangeProcessor(
+    /** @var ScriptPackageInstallationPlugin $this */
+    $this->installation->getPackage(),
+    $tables,
+    WCF::getDB()->getEditor()
+))->process();
diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_wcf1_tag_to_object_step4.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_wcf1_tag_to_object_step4.php
new file mode 100644 (file)
index 0000000..c9ad57a
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * Fourth step of the updates to the `wcf1_tag_to_object` table.
+ *
+ * @author  Matthias Schmidt
+ * @copyright   2001-2021 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core
+ */
+
+use wcf\system\database\table\DatabaseTableChangeProcessor;
+use wcf\system\database\table\index\DatabaseTableIndex;
+use wcf\system\database\table\PartialDatabaseTable;
+use wcf\system\package\plugin\ScriptPackageInstallationPlugin;
+use wcf\system\WCF;
+
+$tables = [
+    PartialDatabaseTable::create('wcf1_tag_to_object')
+        ->indices([
+            DatabaseTableIndex::create()
+                ->columns(['objectTypeID', 'tagID']),
+            DatabaseTableIndex::create()
+                ->columns(['tagID']),
+        ]),
+];
+
+(new DatabaseTableChangeProcessor(
+    /** @var ScriptPackageInstallationPlugin $this */
+    $this->installation->getPackage(),
+    $tables,
+    WCF::getDB()->getEditor()
+))->process();