automatic undo for version control in mysql
I'd like to be able to make a backup, execute migration script and get undo script automatically. 


Why?

If the migration fails so badly that it's going to be abandoned, then restore your backup of the database. 
That's the only way to guarantee that you'll get back to the point you started from. 

I don't know of any way to create an "undo" script but, even if you could, there's no guarantee that it would work, potentially failing part way through its "recovery" and leaving you in an even worse position, somewhere between the last known Good State and the point where the migration failed but you won't be exactly sure where.  From then on, you're clutching at straws to try and clean up the mess. 

Far better ( / easier / more reliable) to toss the "corrupted" database in the bin and restore it from the backup.