From: Alexander Ebert Date: Sun, 21 Sep 2014 14:50:12 +0000 (+0200) Subject: Added support for 'DROP FOREIGN KEY' X-Git-Tag: 2.1.0_Alpha_1~306 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=245424a42794a8fa741b6fe86b78f2dda0a51e93;p=GitHub%2FWoltLab%2FWCF.git Added support for 'DROP FOREIGN KEY' --- diff --git a/wcfsetup/install/files/lib/system/database/util/SQLParser.class.php b/wcfsetup/install/files/lib/system/database/util/SQLParser.class.php index 439ef7b2a9..433f364eb2 100644 --- a/wcfsetup/install/files/lib/system/database/util/SQLParser.class.php +++ b/wcfsetup/install/files/lib/system/database/util/SQLParser.class.php @@ -157,6 +157,10 @@ class SQLParser { else if (preg_match('~^ALTER\s+TABLE\s+(\w+)\s+DROP\s+(?:INDEX|KEY)\s+(\w+)~is', $query, $match)) { $this->executeDropIndexStatement($match[1], $match[2]); } + // drop foreign key + else if (preg_match('~^ALTER\s+TABLE\s+(\w+)\s+DROP\s+FOREIGN KEY\s+(\w+)~is', $query, $match)) { + $this->executeDropForeignKeyStatement($match[1], self::getGenericIndexName($match[1], $match[2], 'fk')); + } // drop column else if (preg_match('~^ALTER\s+TABLE\s+(\w+)\s+DROP\s+(?:COLUMN\s+)?(\w+)~is', $query, $match)) { $this->executeDropColumnStatement($match[1], $match[2]); @@ -278,6 +282,16 @@ class SQLParser { WCF::getDB()->getEditor()->dropIndex($tableName, $indexName); } + /** + * Executes a 'DROP FOREIGN KEY' statement. + * + * @param string $tableName + * @param string $indexName + */ + protected function executeDropForeignKeyStatement($tableName, $indexName) { + WCF::getDB()->getEditor()->dropForeignKey($tableName, $indexName); + } + /** * Executes a 'DROP TABLE' statement. *