Fixed deinstallation of foreign keys
authorMarcel Werk <burntime@woltlab.com>
Tue, 19 Jul 2016 13:54:54 +0000 (15:54 +0200)
committerMarcel Werk <burntime@woltlab.com>
Tue, 19 Jul 2016 13:54:59 +0000 (15:54 +0200)
wcfsetup/install/files/lib/system/package/plugin/SQLPackageInstallationPlugin.class.php

index 6c1872afb0cd5c5d2047cec65964a05f2f93dfb7..563a280ed9b0065a19150565723f0b16f2f352c9 100644 (file)
@@ -83,10 +83,17 @@ class SQLPackageInstallationPlugin extends AbstractPackageInstallationPlugin {
         */
        public function uninstall() {
                // get logged sql tables/columns
-               $sql = "SELECT          *
+               $sql = "SELECT          wcf".WCF_N."_package_installation_sql_log.*,
+                                       CASE WHEN sqlIndex <> '' THEN 1 ELSE 0 END AS isIndex,
+                                       CASE WHEN sqlColumn <> '' THEN 1 ELSE 0 END AS isColumn,
+                                       CASE WHEN SUBSTRING(sqlIndex, -3) = '_fk' THEN 1 ELSE 0 END AS isForeignKey
                        FROM            wcf".WCF_N."_package_installation_sql_log
                        WHERE           packageID = ?
-                       ORDER BY        sqlIndex DESC, sqlColumn DESC";
+                       ORDER BY        isIndex DESC,
+                                       isForeignKey DESC,
+                                       sqlIndex,
+                                       isColumn DESC,
+                                       sqlColumn";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$this->installation->getPackageID()]);
                $entries = $statement->fetchAll(\PDO::FETCH_ASSOC);