in reply to Automatically altering tables from different schema's
I can't give you any pointers to specific code, but I want to point out that the problem is more subtle than you may think. For example, take your second foo table. Is it different from this:
As a human, you can see that the difference is mainly in column order, but also the id and status columns are not qualified as "unsigned". The question is, do these differences matter to you?
create table foo (
id int primary key,
If you're a programmer and you have well-written SQL, then column order in a table does not matter. On the other hand, if you're a DBA, and you're managing a million-row table with varchar(4000) columns, then column order does matter.
It turns out that identifying the differences and overcoming them is mostly the same problem. Even if you can't make the change with an ALTER statement, you could always create a new table and load it from the old one, then rename the results. But the crux of the problem remains: what do you consider a significant difference? Once you've figured that out, the right tool to use will be easier to select.