swguy:
Weird issue:
[30-Jul-2023 18:30:02 UTC] PHP Fatal error: Uncaught mysqli_sql_exception: Incorrect table definition; there can be only one auto column and it must be defined as a key in /Users/scott/sites/client/ConvertDb.php:736
Stack trace:
#0 /Users/scott/sites/client/ConvertDb.php(736): mysqli_query(Object(mysqli), 'ALTER TABLE ze...') #1 /Users/scott/sites/client/ConvertDb.php(375): ConvertDb->doQuery('ALTER TABLE ze...')
#2 /Users/scott/sites/client/convert_database.php(282): ConvertDb->updateTableCollations('zen_better_toge...', 'utf8mb4_unicode...')
#3 {main}
thrown in /Users/scott/sites/client/ConvertDb.php on line 736
What's confusing is that there is only one auto column and it is defined as a key. So I'm not sure why this is failing.
Also, this backtrace was not written to /logs, which might be a feature to add in the next version.
While there is only one AUTO_INCREMENT column in that table, its value is specified as a KEY ... not a PRIMARY KEY. The tool sets a table's AUTO_INCREMENT field as its PRIMARY KEY and then adds any additional table-keys. That's why the error message is being displayed, since the PRIMARY KEY is now the same as the to-be-added KEY.
CREATE TABLE `zen_better_together_admin` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`linkage_type` char(20) CHARACTER SET utf8mb4 NOT NULL,
`field1` int(11) NOT NULL DEFAULT '0',
`field2` int(11) NOT NULL DEFAULT '0',
`active` char(1) CHARACTER SET utf8mb4 NOT NULL DEFAULT 'Y',
`discount_units` char(1) CHARACTER SET utf8mb4 NOT NULL DEFAULT '%',
`discount_amount` decimal(15,4) NOT NULL DEFAULT '0.0000',
`date_added` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
`start_date` date NOT NULL DEFAULT '0001-01-01',
`end_date` date NOT NULL DEFAULT '0001-01-01',
KEY `idx` (`id`),
KEY `idx_date_added` (`date_added`)
) ENGINE=MyISAM AUTO_INCREMENT=44 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
The tool uses *only *a site's /includes/local/configure.php (if present) and the /includes/configure.php to determine the database-related configuration values, so it's not aware of the site's /logs sub-directory. That's why the error(s) aren't created in a log file.
Note: I'm running my testing with the following MySQL configuration settings:
define('DB_MYSQL_MODE', 'ONLY_FULL_GROUP_BY, STRICT_TRANS_TABLES, NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION');