#Step 1. Dump/export table creation sql # Note table and field names enclosed in backquotes #Step 2. Run this filter on it to create alter patch #Step 3. Manually add commands to drop keys, drop and create table / field to top of patch. # Note: created tables and fields needn't be accurate, they just need to exist #Step 4. Run this patch on the database while (<>) { s/^\s*CREATE TABLE (`\w+`) \(/ALTER TABLE $1\n/; s/^\s*(`\w+`)/ CHANGE $1 $1/; s/^\s*PRIMARY KEY/ DROP PRIMARY KEY, ADD PRIMARY KEY/; s/^\s*UNIQUE KEY (`\w+`)/ DROP INDEX $1, ADD UNIQUE $1/; s/^\s*KEY (`\w+`)/ DROP INDEX $1, ADD INDEX $1/; s/^\)//; s/ENGINE=(\w+)/ ENGINE=$1,\n/; s/DEFAULT CHARSET=(\w+)/ DEFAULT CHARSET=$1/; s/^\s+(.+?),?\s*$/ $1,\n/; print; }