Re: Differences between two mySQL Databases
| From: | Greg Donald | Date: | Tue, 25 Jun 2002 21:55:57 +0000 |
| Subject: | Re: Differences between two mySQL Databases | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-20105@lists.php.net to get a copy of this message | ||
On Tue, 25 Jun 2002, Michael Robbins wrote:
>I'm looking for a utility that can compare two database structures and
>generate a SQL statement that will duplicate the differences.
>
>I'm using mySQL and I have both live and development databases. While
>working on the development database, I frequently make changes to table
>structures, adding/removing tables or columns, changing column types, or
>adding/removing indexes.
>
>When I'm ready to move my changes to the live site, I'd like to just
>compare the two databases, and have it generate a SQL statement that I
>can run on my live database, so that it's structure will match my
>development database. This would be much easier than trying to make all
>of the changes manually, or writing my own script to make the changes
>(how would you test this? Can't test it on the development database, the
>changes are already there. Can't test it on the live database, what if
>there's a mistake of some kind?)
Do a diff on the two tables descriptions.
mysql -uuser -ppass database1 -e 'desc sometable' > sometable1 &&
mysql -uuser -ppass database2 -e 'desc sometable' > sometable2 &&
diff sometable1 sometable2 > difference
cat difference
--
-----------------------------------------------------------------------
Greg Donald
http://destiney.com/public.key
-----------------------------------------------------------------------