View Single Post
Old 10-27-2020, 09:34 PM
aim aim is offline
Advanced Staff Users

X-Cart team
Join Date: Dec 2008
Posts: 928

Default Re: X-Cart 4.7.12 released

Originally Posted by
This is an 'old' upgrade pack that I downloaded on May 31st, I will download a new one & check if the problem is resolved.


I have downloaded a new patch from 4.7.9 to 4.7.12 & it gives the same error when upgrading:
SQL PATCH ``patch.sql'' FAILED AT QUERIES: ALTER TABLE xcart_modules ADD UNIQUE KEY `module_name` (`module_name`);

But if the solution is to change the INDEX on module_name to UNIQUE, than I will just do that?


There is a code before the ALTER statement which should safely remove duplicates to avoid such errors.

-- remove duplicates from xCart_mOdules CREATE TABLE IF NOT EXISTS _xcart_modules_orig_aim_ ( moduleid int NOT NULL AUTO_INCREMENT, module_name varchar(255) NOT NULL DEFAULT '', module_descr varchar(255) NOT NULL DEFAULT '', `active` char(1) NOT NULL DEFAULT 'Y', init_orderby varchar(255) NOT NULL DEFAULT '', author varchar(255) NOT NULL DEFAULT 'other', module_url varchar(255) NOT NULL DEFAULT '', tags varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (moduleid), UNIQUE KEY module_name (module_name) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT IGNORE INTO _xcart_modules_orig_aim_ SELECT moduleid,module_name,module_descr,`active`,init_orderby,author,module_url,tags FROM xcart_modules ORDER BY active DESC, moduleid; DELETE FROM xcart_modules WHERE moduleid NOT IN (SELECT moduleid FROM _xcart_modules_orig_aim_); DROP TABLE _xcart_modules_orig_aim_; -- ALTER TABLE xcart_modules ADD UNIQUE KEY `module_name` (`module_name`);

but you got the idea correctly
You can remove the whole block if your module_name is already UNIQUE KEY

Thank you.
Sincerely yours,
Ildar Amankulov
Head of Maintenance group
Reply With Quote