Make `wcf1_package.package` have a unique key
authorMatthias Schmidt <gravatronics@live.com>
Sun, 10 Nov 2019 09:37:54 +0000 (10:37 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 10 Nov 2019 09:37:54 +0000 (10:37 +0100)
Close #3099

com.woltlab.wcf/package.xml
wcfsetup/install/files/acp/update-com.woltlab.wcf_5.2.0_beta_3.php [new file with mode: 0644]
wcfsetup/setup/db/install.sql

index f50389fca98bfd77b2f7e59c2b61b012d9432724..e8fce6992fec950579d046825ca193cc4b4fa46b 100644 (file)
@@ -54,6 +54,7 @@
                <instruction type="acpTemplate">acptemplates_update.tar</instruction>
                <instruction type="file">files_update.tar</instruction>
                <instruction type="template">templates_update.tar</instruction>
+               <instruction type="script">acp/update-com.woltlab.wcf_5.2.0_beta_3.php</instruction>
                
                <instruction type="language" />
        </instructions>
diff --git a/wcfsetup/install/files/acp/update-com.woltlab.wcf_5.2.0_beta_3.php b/wcfsetup/install/files/acp/update-com.woltlab.wcf_5.2.0_beta_3.php
new file mode 100644 (file)
index 0000000..dee5ddc
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+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;
+
+/**
+ * Updates the database table layout from WoltLab Suite Core 5.2.0 Beta 2 to 5.2.0 Beta 3.
+ *
+ * @author     Matthias Schmidt
+ * @copyright  2001-2019 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ */
+
+$tables = [
+       PartialDatabaseTable::create('wcf1_package')
+               ->indices([
+                       DatabaseTableIndex::create('package')
+                               ->columns(['package'])
+                               ->drop(),
+                       
+                       DatabaseTableIndex::create()
+                               ->type(DatabaseTableIndex::UNIQUE_TYPE)
+                               ->columns(['package'])
+               ])
+];
+
+(new DatabaseTableChangeProcessor(
+/** @var ScriptPackageInstallationPlugin $this */
+       $this->installation->getPackage(),
+       $tables,
+       WCF::getDB()->getEditor())
+)->process();
index 5c751c48e1889e093f23220d1617098303939d61..2cf567d6e9e5bc2555bec2f53b0f9dbda096d32e 100644 (file)
@@ -910,7 +910,7 @@ CREATE TABLE wcf1_package (
        isApplication TINYINT(1) NOT NULL DEFAULT 0,
        author VARCHAR(255) NOT NULL DEFAULT '',
        authorURL VARCHAR(255) NOT NULL DEFAULT '',
-       KEY package (package)
+       UNIQUE KEY package (package)
 );
 
 DROP TABLE IF EXISTS wcf1_package_compatibility;