Skip to content

Instantly share code, notes, and snippets.

@matdave
Last active August 3, 2018 14:31
Show Gist options
  • Save matdave/7617ac74c0a61e72be72a3a5d111874c to your computer and use it in GitHub Desktop.
Save matdave/7617ac74c0a61e72be72a3a5d111874c to your computer and use it in GitHub Desktop.
Change Prefix to MODX in MySQL
/* Drop MODX */
SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' )
AS statement FROM information_schema.TABLES WHERE table_schema = 'instance_cXXXX_modx' AND table_name LIKE 'modx_%';
/* Change incorrect prefix */
SELECT CONCAT( 'RENAME TABLE ', TABLE_NAME, ' TO ', replace(TABLE_NAME, 'wrong_', 'modx_'), ';')
AS statement FROM information_schema.TABLES WHERE table_schema = 'instance_cXXXX_modx' AND table_name LIKE 'wrong_%';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment