Installation of extensions fixes
authorRoland Häder <roland@mxchange.org>
Tue, 27 Nov 2012 23:01:45 +0000 (23:01 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 27 Nov 2012 23:01:45 +0000 (23:01 +0000)
- Again some extensions has not been fully rewritten to newly introduced
  wrapper functions which caused them to not install
- An extra back-tick (`) was found in column name :(
- Added optional $forceFound variable which can be used to (if the table is
  missing) that the column/key is marked as "found"
- Expanded debug messages with column/key name and $forceFound variable
- TODOs.txt updated

DOCS/TODOs.txt
inc/db/lib-mysql3.php
inc/extensions-functions.php
inc/extensions/ext-refback.php
inc/extensions/ext-sql_patches.php
inc/extensions/ext-task.php
inc/extensions/ext-user.php
inc/filters.php
inc/fix_menu.php

index 6c65c7f19700fa222a9ce98279a5589a2be3305c..6488912587ea4fe9b4f3ce264a08bea2576af34a 100644 (file)
 ./inc/extensions/ext-nickname.php:52:          // @TODO NOT NULL DEFAULT '' is bad practice, use NULL
 ./inc/extensions/ext-yoomedia.php:121:         // @TODO Can this be moved into a database table?
 ./inc/extensions/ext-yoomedia.php:54:// @TODO Only deprecated when 'ext-network' is ready! setExtensionDeprecated('Y');
-./inc/extensions-functions.php:2172:// @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable'
+./inc/extensions-functions.php:2176:// @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable'
 ./inc/extensions-functions.php:424:    // @TODO This redirect is still needed to register sql_patches! Please try to avoid it
 ./inc/extensions-functions.php:440:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) )
 ./inc/extensions-functions.php:580:            // @TODO Extension is loaded, what next?
 ./inc/filter/bonus_filter.php:56:              // @TODO This query isn't right, it will only update if the user was for a longer time away!
 ./inc/filter/cache_filter.php:94:              // @TODO This should be rewritten not to load the cache file for just checking if it is there for save removal.
 ./inc/filter/forced_filter.php:73:             // @TODO This part is unfinished
-./inc/filters.php:1320:                // @TODO No banner found, output some default banner
+./inc/filters.php:1317:                // @TODO No banner found, output some default banner
 ./inc/functions.php:1104:                      // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ?
 ./inc/functions.php:1190:                      // @TODO Are these convertions still required?
 ./inc/functions.php:1211:// @TODO Rewrite this function to use readFromFile() and writeToFile()
index 2457c6a4741ff78c03f77616ac844ff8710d7ff0..e9ebc79cfc809ad94531d37cfd489051f5095556 100644 (file)
@@ -668,7 +668,7 @@ function ifSqlTableExists ($tableName) {
 }
 
 // Is a table column there?
-function ifSqlTableColumnExists ($tableName, $columnName) {
+function ifSqlTableColumnExists ($tableName, $columnName, $forceFound = FALSE) {
        // Remove back-ticks
        $columnName = str_replace('`', '', $columnName);
 
@@ -678,8 +678,8 @@ function ifSqlTableColumnExists ($tableName, $columnName) {
        // If the table is not there, it is okay
        if (!ifSqlTableExists($tableName)) {
                // Then abort here
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Table ' . $tableName . ' does not exist.');
-               return FALSE;
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Table ' . $tableName . ' does not exist, columnName=' . $columnName . ',forceFound=' . intval($forceFound));
+               return (($forceFound === FALSE) && (isInstallationPhase()));
        } // END - if
 
        // Get column information
@@ -695,7 +695,7 @@ function ifSqlTableColumnExists ($tableName, $columnName) {
                if (isInstallationPhase()) {
                        // Then silently abort here
                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'result[]=' . gettype($result) . ',isLinkUp=' . intval(SQL_IS_LINK_UP()) . ',tableName=' . $tableName . ',columnName=' . $columnName . ' - Returning FALSE ...');
-                       return FALSE;
+                       return $forceFound;
                } else {
                        // Please report this
                        reportBug(__FUNCTION__, __LINE__, 'result[]=' . gettype($result) . ' is not a resource.');
@@ -714,7 +714,7 @@ function ifSqlTableColumnExists ($tableName, $columnName) {
 }
 
 // Checks depending on the mode if the index is there
-function ifSqlTableIndexExist ($tableName, $keyName) {
+function ifSqlTableIndexExist ($tableName, $keyName, $forceFound = FALSE) {
        // Remove back-ticks
        $keyName = str_replace('`', '', $keyName);
 
@@ -724,8 +724,8 @@ function ifSqlTableIndexExist ($tableName, $keyName) {
        // If the table is not there, it is okay
        if (!ifSqlTableExists($tableName)) {
                // Then abort here
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Table ' . $tableName . ' does not exist.');
-               return FALSE;
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Table ' . $tableName . ' does not exist, keyName=' . $keyName . ',forceFound=' . intval($forceFound));
+               return (($forceFound === FALSE) && (isInstallationPhase()));
        } // END - if
 
        // Show indexes
@@ -737,14 +737,14 @@ function ifSqlTableIndexExist ($tableName, $keyName) {
                if (isInstallationPhase()) {
                        // Then silently abort here
                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'result[]=' . gettype($result) . ',isLinkUp=' . intval(SQL_IS_LINK_UP()) . ',tableName=' . $tableName . ',keyName=' . $keyName . ' - Returning FALSE ...');
-                       return FALSE;
+                       return $forceFound;
                } else {
                        // Please report this
                        reportBug(__FUNCTION__, __LINE__, 'result[]=' . gettype($result) . ' is not a resource.');
                }
        } // END - if
 
-       // The column is not found by default
+       // The key is not found by default
        $doesExist = FALSE;
 
        // Walk through all
index 435f7b92d3d9fa44f3bf49b8825227924890d450..e6fcb897ee6fc3ea7ff75d0c544d1530da27cfda 100644 (file)
@@ -357,7 +357,7 @@ function registerExtension ($ext_name, $taskId, $isDryRun = FALSE, $ignoreUpdate
                                setSqlsArray(getExtensionSqls());
 
                                // Run installation pre-installation filters
-                               runFilterChain('pre_extension_installed', array('dry_run' => isExtensionDryRun(), 'enable_codes' => FALSE));
+                               runFilterChain('pre_extension_installed', array('dry_run' => isExtensionDryRun(), 'ext_installing' => TRUE, 'enable_codes' => FALSE));
 
                                // Register extension
                                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'insert=' . getCurrentExtensionName() . '/' . getCurrentExtensionVersion() . ' - INSERT!');
@@ -771,7 +771,7 @@ function updateExtension ($ext_name, $ext_ver, $isDryRun = FALSE, $ignoreDepende
                setSqlsArray(getExtensionSqls());
 
                // Run SQLs
-               runFilterChain('run_sqls', array('dry_run' => isExtensionDryRun(), 'enable_codes' => FALSE));
+               runFilterChain('run_sqls', array('dry_run' => isExtensionDryRun(), 'ext_installing' => TRUE, 'enable_codes' => FALSE));
 
                if (isExtensionDryRun() === FALSE) {
                        // Run filters on success extension update
@@ -1543,10 +1543,14 @@ function initExtensionSqls ($force = FALSE) {
 
 // Adds SQLs to the SQLs array but "assigns" it with current extension name
 function addExtensionSql ($sql) {
+       // Copy current name/version to local variable
+       $currentName    = getCurrentExtensionName();
+       $currentVersion = getCurrentExtensionVersion();
+
        // Is is the array there?
-       if ((!isset($GLOBALS['ext_sqls'][getCurrentExtensionName()][getCurrentExtensionVersion()])) || (!is_array($GLOBALS['ext_sqls'][getCurrentExtensionName()][getCurrentExtensionVersion()]))) {
+       if ((!isset($GLOBALS['ext_sqls'][$currentName][$currentVersion])) || (!is_array($GLOBALS['ext_sqls'][$currentName][$currentVersion]))) {
                // Init array
-               $GLOBALS['ext_sqls'][getCurrentExtensionName()][getCurrentExtensionVersion()] = array();
+               $GLOBALS['ext_sqls'][$currentName][$currentVersion] = array();
        } // END - if
 
        // Is the SQL statement empty?
@@ -1560,8 +1564,8 @@ function addExtensionSql ($sql) {
        } // END - if
 
        // Add it
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . getCurrentExtensionName() . ',ext_version=' . getCurrentExtensionVersion() . ',sql=' . $sql);
-       array_push($GLOBALS['ext_sqls'][getCurrentExtensionName()][getCurrentExtensionVersion()], $sql);
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $currentName . ',ext_version=' . $currentVersion . ',sql=' . $sql);
+       array_push($GLOBALS['ext_sqls'][$currentName][$currentVersion], $sql);
 }
 
 // Getter for SQLs array for current extension
@@ -2000,7 +2004,7 @@ function addSponsorMenuSql ($action, $what, $title, $active, $sort) {
 // Add ALTER TABLE `foo` ADD sql if not found
 function addExtensionAddTableColumnSql ($tableName, $columnName, $columnSql) {
        // Is the column there?
-       if (!ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $columnName)) {
+       if (!ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $columnName, isInstallationPhase())) {
                // Then add it
                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` ADD `' . $columnName . '` ' . $columnSql);
        } elseif (isDebugModeEnabled()) {
@@ -2012,7 +2016,7 @@ function addExtensionAddTableColumnSql ($tableName, $columnName, $columnSql) {
 // Add ALTER TABLE `foo` ADD INDEX sql if not found
 function addExtensionAddTableIndexSql ($tableName, $indexName, $columnSql) {
        // Is the column there?
-       if (!ifSqlTableIndexExist('{?_MYSQL_PREFIX?}_' . $tableName, $indexName)) {
+       if (!ifSqlTableIndexExist('{?_MYSQL_PREFIX?}_' . $tableName, $indexName, isInstallationPhase())) {
                // Then add it
                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` ADD INDEX `' . $indexName . '` ' . $columnSql);
        } elseif (isDebugModeEnabled()) {
@@ -2024,7 +2028,7 @@ function addExtensionAddTableIndexSql ($tableName, $indexName, $columnSql) {
 // Add ALTER TABLE `foo` ADD UNIQUE INDEX sql if not found
 function addExtensionAddTableUniqueSql ($tableName, $indexName, $columnSql) {
        // Is the column there?
-       if (!ifSqlTableIndexExist('{?_MYSQL_PREFIX?}_' . $tableName, $indexName)) {
+       if (!ifSqlTableIndexExist('{?_MYSQL_PREFIX?}_' . $tableName, $indexName, isInstallationPhase())) {
                // Then add it
                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` ADD UNIQUE INDEX `' . $indexName . '` ' . $columnSql);
        } elseif (isDebugModeEnabled()) {
@@ -2035,8 +2039,8 @@ function addExtensionAddTableUniqueSql ($tableName, $indexName, $columnSql) {
 
 // Add ALTER TABLE `foo` ADD FULLTEXT sql if not found
 function addExtensionAddTableFulltextSql ($tableName, $indexName, $columnSql) {
-       // Is the column there?
-       if (!ifSqlTableIndexExist('{?_MYSQL_PREFIX?}_' . $tableName, $indexName)) {
+       // Is the column there and MyISAM engine? (InnoDB doesn't support FULLTEXT)
+       if ((getTableType() == 'MyISAM') && (!ifSqlTableIndexExist('{?_MYSQL_PREFIX?}_' . $tableName, $indexName, isInstallationPhase()))) {
                // Then add it
                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` ADD FULLTEXT `' . $indexName . '` ' . $columnSql);
        } elseif (isDebugModeEnabled()) {
@@ -2048,7 +2052,7 @@ function addExtensionAddTableFulltextSql ($tableName, $indexName, $columnSql) {
 // Add ALTER TABLE `foo` CHANGE sql if not found
 function addExtensionChangeTableColumnSql ($tableName, $fromColumnName, $toColumnName, $columnSql) {
        // Is the column there?
-       if ((ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $fromColumnName)) && (($fromColumnName == $toColumnName) || (!ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $toColumnName)))) {
+       if ((ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $fromColumnName)) && (($fromColumnName == $toColumnName) || (!ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $toColumnName, isInstallationPhase())))) {
                // Then add it
                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` CHANGE `' . $fromColumnName . '` `' . $toColumnName . '` ' . $columnSql);
        } elseif (isDebugModeEnabled()) {
@@ -2060,7 +2064,7 @@ function addExtensionChangeTableColumnSql ($tableName, $fromColumnName, $toColum
 // Add ALTER TABLE `foo` DROP sql if not found
 function addExtensionDropTableColumnSql ($tableName, $columnName) {
        // Is the column there?
-       if (ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $columnName)) {
+       if (ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $columnName, isInstallationPhase())) {
                // Then add it
                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` DROP `' . $columnName . '`');
        } elseif (isDebugModeEnabled()) {
@@ -2072,7 +2076,7 @@ function addExtensionDropTableColumnSql ($tableName, $columnName) {
 // Add ALTER TABLE `foo` DROP INDEX sql if not found
 function addExtensionDropTableIndexSql ($tableName, $indexName) {
        // Is the column there?
-       if (ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $indexName)) {
+       if (ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $indexName, isInstallationPhase())) {
                // Then add it
                addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` DROP INDEX `' . $indexName . '`');
        } elseif (isDebugModeEnabled()) {
index 192176096e86feffaa1945380682cc98392859b5..b6252421eac7c347da22e80b25988232b300be56 100644 (file)
@@ -108,8 +108,8 @@ switch (getExtensionMode()) {
                                addExtensionDependency('user');
 
                                // SQL commands to run - drop old first, add new next
-                               addExtensionDropTableColumnSql('user_refs', 'refback`');
-                               addExtensionDropTableColumnSql('user_refs', 'points`');
+                               addExtensionDropTableColumnSql('user_refs', 'refback');
+                               addExtensionDropTableColumnSql('user_refs', 'points');
                                addExtensionAddTableColumnSql('user_refs', 'refback_percents', 'FLOAT(4,1) NOT NULL DEFAULT 0.0');
                                addExtensionAddTableColumnSql('user_refs', 'refback_points', 'FLOAT(20,5) NOT NULL DEFAULT 0.00000');
 
index 40a8e3a95d5e5741d5bf98581b29f5604057f19c..a4cb1d7e67c03e1f0f1de45063d5ebb1d3eaf37d 100644 (file)
@@ -355,11 +355,6 @@ IN (
                                addExtensionAddTableUniqueSql('mod_reg', 'module', '(`module`)');
                                addExtensionAddTableIndexSql('admin_menu', 'action', '(`action`)');
                                addExtensionAddTableIndexSql('admin_menu', 'what', '(`what`)');
-                               addExtensionAddTableIndexSql('task_system', 'task_type', '(`task_type`)');
-                               addExtensionAddTableIndexSql('task_system', 'status', '(`status`)');
-                               addExtensionAddTableIndexSql('task_system', 'task_created', '(`task_created`)');
-                               addExtensionAddTableFulltextSql('task_system', 'subject', '(`subject`)');
-                               addExtensionAddTableIndexSql('task_system', 'subject', '(`subject`)');
                                addExtensionAddTableIndexSql('extensions', 'ext_active', '(`ext_active`)');
                                addExtensionAddTableIndexSql('guest_menu', 'action', '(`action`)');
                                addExtensionAddTableIndexSql('guest_menu', 'what', '(`what`)');
@@ -549,10 +544,8 @@ INDEX (`admin_id`)",
                                break;
 
                        case '0.4.8': // SQL queries for v0.4.8
-                               addExtensionAddTableIndexSql('task_system', 'subject', '(`subject`)');
-
                                // Update notes (these will be set as task text!)
-                               setExtensionUpdateNotes("Index f&uuml;r Betreff eingef&uuml;gt.");
+                               setExtensionUpdateNotes("Update nach <strong>ext-task</strong> verschoben.");
                                break;
 
                        case '0.4.9': // SQL queries for v0.4.9
@@ -561,8 +554,8 @@ INDEX (`admin_id`)",
                                break;
 
                        case '0.5.0': // SQL queries for v0.5.0
-                               addExtensionDropTableIndexSql('refsystem', 'level`');
-                               addExtensionDropTableIndexSql('refsystem', 'userid`');
+                               addExtensionDropTableIndexSql('refsystem', 'level');
+                               addExtensionDropTableIndexSql('refsystem', 'userid');
                                addExtensionAddTableIndexSql('refsystem', 'userid_level', '(`userid`, `level`)');
 
                                // Update notes (these will be set as task text!)
@@ -618,7 +611,7 @@ INDEX (`admin_id`)",
                                break;
 
                        case '0.5.8': // SQL queries for v0.5.8
-                               addExtensionDropTableColumnSql('extensions` DROP `ext_lang_file`');
+                               addExtensionDropTableColumnSql('extensions', 'ext_lang_file');
 
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes("Sprachdateinamen werden nicht mehr in der Datenbank behalten.");
index 41d0eb429ab334f6ba0448b6a44b0ad75ce7e06f..29945d6c925c7399357e3db5709cb0fc5f901155 100644 (file)
@@ -55,6 +55,13 @@ switch (getExtensionMode()) {
                addAdminMenuSql('task', NULL, 'Aufgaben-Management','Erweitertes Aufgaben-Management zur leichten verwaltung der vom System erzeugten Aufgaben.',1);
                addAdminMenuSql('task','list_task','Aufgaben auflisten','Alle Ihnen zugewiesenen Aufgaben auflisten (keine Updates).',1);
                addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `status`='SOLVED' WHERE `status`='CLOSED'");
+               // These SQL updates has been moved from ext-sql_patches to here
+               addExtensionAddTableIndexSql('task_system', 'task_type', '(`task_type`)');
+               addExtensionAddTableIndexSql('task_system', 'status', '(`status`)');
+               addExtensionAddTableIndexSql('task_system', 'task_created', '(`task_created`)');
+               addExtensionAddTableFulltextSql('task_system', 'subject', '(`subject`)');
+               addExtensionAddTableIndexSql('task_system', 'subject', '(`subject`)');
+               addExtensionAddTableIndexSql('task_system', 'subject', '(`subject`)');
                break;
 
        case 'remove': // Do stuff when removing extension
index 4396672e91339df3060d25e3dc7d3cccd07b0c27..de7aab71a45249fa1599546d6ddd4420a7dfcdd8 100644 (file)
@@ -386,7 +386,7 @@ INDEX (`userid`)",
                                break;
 
                        case '0.3.6': // SQL queries for v0.3.6
-                               addExtensionDropTableIndexSql('user_cats', 'userid`');
+                               addExtensionDropTableIndexSql('user_cats', 'userid');
                                addExtensionAddTableUniqueSql('user_cats', 'userid_catid', '(`userid`, `cat_id`)');
 
                                // Update notes (these will be set as task text!)
@@ -396,7 +396,6 @@ INDEX (`userid`)",
                        case '0.3.7': // SQL queries for v0.3.7
                                addExtensionChangeTableColumnSql('user_points', 'id', 'id', 'BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT');
                                addExtensionChangeTableColumnSql('user_points', 'userid', 'userid', 'BIGINT(20) UNSIGNED NULL DEFAULT NULL');
-                               addExtensionChangeTableColumnSql('user_points', 'cat_id', 'cat_id', 'TINYINT(3) UNSIGNED NULL DEFAULT NULL');
                                addExtensionChangeTableColumnSql('user_data', 'userid', 'userid', 'BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT');
                                addExtensionChangeTableColumnSql('user_del', 'userid', 'userid', 'BIGINT(20) UNSIGNED NULL DEFAULT NULL');
                                addExtensionChangeTableColumnSql('user_links', 'stats_id', 'stats_id', 'BIGINT(20) UNSIGNED NULL DEFAULT NULL');
index 98cf7eb463e529d324a5defeeccc9524566c195b..0c6b4980219f94f7cae42e6c628141f3aa84b50d 100644 (file)
@@ -277,8 +277,8 @@ function FILTER_RUN_SQLS ($filterData) {
 
                                // Is there still a query left?
                                if (!empty($sql)) {
-                                       // Is there an "ALTER TABLE" command?
-                                       if (substr(strtolower($sql), 0, 11) == 'alter table') {
+                                       // Is there an "ALTER TABLE" command? Exclude installation phase here as it would cause this query to fail
+                                       if ((substr(strtolower($sql), 0, 11) == 'alter table') && (!isset($filterData['ext_installing']))) {
                                                // Analyse the alteration command
                                                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Alterting table: ' . $sql . ',enable_codes=' . intval($filterData['enable_codes']));
                                                SQL_ALTER_TABLE($sql, __FUNCTION__, __LINE__, $filterData['enable_codes']);
@@ -301,9 +301,6 @@ function FILTER_RUN_SQLS ($filterData) {
        // Debug message
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '- Left!');
 
-       // Clear any SQL queries
-       //initSqls();
-
        // Return counter
        return $count;
 }
index 5fbfcab34de67a153b1efe2c87ebc0f0cc2a639c..62515a9601d59ffc30c07a971e2d54fcd65c65de 100644 (file)
@@ -98,11 +98,11 @@ foreach (array('guest','member','admin') as $menu) {
        initSqls();
 
        // Now insert our unqiue key for action-what combination
-       addSql(sprintf("ALTER TABLE `{?_MYSQL_PREFIX?}_%s_menu` DROP KEY `action_what`", $menu));
+       addSql(sprintf("ALTER TABLE `{?_MYSQL_PREFIX?}_%s_menu` DROP INDEX `action_what`", $menu));
        addSql(sprintf("ALTER TABLE `{?_MYSQL_PREFIX?}_%s_menu` ADD UNIQUE INDEX `action_what` (`action`, `what`)", $menu));
 
        // Now insert our unqiue key for what
-       addSql(sprintf("ALTER TABLE `{?_MYSQL_PREFIX?}_%s_menu` DROP KEY `what`", $menu));
+       addSql(sprintf("ALTER TABLE `{?_MYSQL_PREFIX?}_%s_menu` DROP INDEX `what`", $menu));
        addSql(sprintf("ALTER TABLE `{?_MYSQL_PREFIX?}_%s_menu` ADD UNIQUE INDEX `what` (`what`)", $menu));
 
        // And run all