Skip to content

Instantly share code, notes, and snippets.

@toby78
Created October 14, 2016 20:59
Show Gist options
  • Save toby78/53678d951b43b6046a09f55875f48aa7 to your computer and use it in GitHub Desktop.
Save toby78/53678d951b43b6046a09f55875f48aa7 to your computer and use it in GitHub Desktop.
<?php
require_once("config.php");
mysql_connect($dbhost, $dbuname, $dbpass);
@mysql_select_db($dbname) or die ("???");
$result=mysql_query("SELECT table_schema, table_name FROM INFORMATION_SCHEMA.TABLES
WHERE engine = 'MyISAM' and table_schema not in ('mysql','information_schema')");
while (list($database,$table) = mysql_fetch_array($result))
{
echo $database; echo "-".$table; echo "\n";
echo "pt-online-schema-change --alter \"ENGINE=InnoDB\" D=".$database.",t=".$table."\n";
echo exec("pt-online-schema-change --alter \"ENGINE=InnoDB\" D=".$database.",t=".$table." -u".$dbuname." -p".$dbpass." --alter-foreign-keys-method=auto --execute");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment