Fixed SQL update
authorAlexander Ebert <ebert@woltlab.com>
Tue, 26 Nov 2013 13:03:46 +0000 (14:03 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 26 Nov 2013 13:03:46 +0000 (14:03 +0100)
com.woltlab.wcf/package.xml
com.woltlab.wcf/update_rc3.sql
wcfsetup/install/files/acp/update_rc1.php [deleted file]
wcfsetup/install/files/acp/update_rc3.php [new file with mode: 0644]

index f6280671d2345a965bf4f67fcc195bd6eb01628e..68ff0ac51e889e6cf65daf1a1f4670b3c7bf830c 100644 (file)
@@ -48,6 +48,9 @@
                <instruction type="file">files_update.tar</instruction>
                <instruction type="template">templates_update.tar</instruction>
                <instruction type="language">language/*.xml</instruction>
+               
+               <instruction type="script" run="standalone">acp/update_rc3.php</instruction>
+               
                <instruction type="sql">update_rc3.sql</instruction>
                
                <instruction type="option">option.xml</instruction>
index d59f190baedc1d6bac9cd79db4ee8b7d089a069f..91e3e23d9050fd7750e2b5cdc46f940617652883 100644 (file)
@@ -1,4 +1,3 @@
 /* d2fbb3b */
-UPDATE wcf1_user_rank CHANGE groupID groupID INT(10) NOT NULL;
-ALTER TABLE wcf1_user_rank DROP KEY groupID;
+ALTER TABLE wcf1_user_rank CHANGE groupID groupID INT(10) NOT NULL;
 ALTER TABLE wcf1_user_rank ADD FOREIGN KEY (groupID) REFERENCES wcf1_user_group ON DELETE CASCADE;
diff --git a/wcfsetup/install/files/acp/update_rc1.php b/wcfsetup/install/files/acp/update_rc1.php
deleted file mode 100644 (file)
index bb3f4a6..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\system\WCF;
-
-/**
- * @author     Alexander Ebert
- * @copyright  2001-2013 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @category   Community Framework
- */
-
-// remove outdated language items
-$conditions = new PreparedStatementConditionBuilder();
-$conditions->add("languageItem IN (?)", array(array(
-       'wcf.date.month.jan',
-       'wcf.date.month.feb',
-       'wcf.date.month.mar',
-       'wcf.date.month.apr',
-       // may is intentionally left out because it conflicts with the full month name
-       'wcf.date.month.jun',
-       'wcf.date.month.jul',
-       'wcf.date.month.aug',
-       'wcf.date.month.sep',
-       'wcf.date.month.oct',
-       'wcf.date.month.nov',
-       'wcf.date.month.dec'
-)));
-$sql = "DELETE FROM    wcf".WCF_N."_language_item
-       ".$conditions;
-$statement = WCF::getDB()->prepareStatement($sql);
-$statement->execute($conditions->getParameters());
diff --git a/wcfsetup/install/files/acp/update_rc3.php b/wcfsetup/install/files/acp/update_rc3.php
new file mode 100644 (file)
index 0000000..6cf554c
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+use wcf\system\WCF;
+
+/**
+ * @author     Alexander Ebert
+ * @copyright  2001-2013 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @category   Community Framework
+ */
+
+// commit d2fbb3b
+
+// search for foreign key name and drop it
+$sql = "SHOW INDEX FROM wcf".WCF_N."_user_rank";
+$statement = WCF::getDB()->prepareStatement($sql);
+$statement->execute();
+while ($row = $statement->fetchArray()) {
+       if ($row['Column_name'] == 'groupID' && preg_match('~_fk$~', $row['Key_name'])) {
+               // drop key
+               WCF::getDB()->getEditor()->dropForeignKey("wcf".WCF_N."_user_rank", $row['Key_name']);
+               
+               // remove key from sql log
+               $sql = "DELETE FROM     wcf".WCF_N."_package_installation_sql_log
+                       WHERE           sqlTable = ?
+                                       AND sqlIndex = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array(
+                       "wcf".WCF_N."_user_rank",
+                       $row['Key_name']
+               ));
+               
+               break;
+       }
+}