Skip to content

Instantly share code, notes, and snippets.

@brihter
Last active September 19, 2023 11:26
Show Gist options
  • Save brihter/8800941 to your computer and use it in GitHub Desktop.
Save brihter/8800941 to your computer and use it in GitHub Desktop.
The script will generate the missing opencart indexes. Copy the result and execute it on the target schema.
use information_schema;
select
concat('alter table `', c.table_name, '` add index `ix_', c.column_name, '` (`',c.column_name,'`);')
from columns c
where c.table_schema = 'SCHEMA_NAME'
and lower(c.column_name) like '%_id%'
and c.column_key = '';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment