Incorrectly defined tables

Updating older table definitions

Older versions of some Zen Cart plugins created tables that are no longer valid. For example:

CREATE TABLE `admin_files` (
  `id` int(11) NOT NULL,
  `page` varchar(64) NOT NULL DEFAULT '',
  `header` tinyint(4) NOT NULL DEFAULT 0,
  `submenu` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=MyISAM;

ALTER TABLE `admin_files`
  ADD UNIQUE KEY `id` (`id`);

The problem with this is that it won’t work when you convert to UTF8MB4.

You will get the message:

ALTER TABLE `admin_files` DROP INDEX `id`
1075: Incorrect table definition; there can be only one auto column and it must be defined as a key

Issues like this must be fixed manually in phpMyAdmin.

ALTER TABLE admin_files ADD PRIMARY KEY (id);
ALTER TABLE admin_files DROP KEY id;



Still have questions? Use the Search box in the upper right, or try the full list of FAQs. If you can't find it there, head over to the Zen Cart support forum and ask there in the appropriate subforum. In your post, please include your Zen Cart and PHP versions, and a link to your site.

Is there an error or omission on this page? Please post to General Questions on the support forum. Or, if you'd like to open a pull request, just review the guidelines and get started. You can even PR right here.
Last modified October 28, 2024 by Scott Wilson (bf2b50ec).