Beanow
Beanow

Reputation: 1109

Take the difference in two SQL dumps for update/alter statements?

Are there libraries that focus on taking two database exports, finding the differences and creating update/alter statements for it? Basically an update script from export A to export B.

For instance this:

-- Version 1
CREATE TABLE IF NOT EXISTS `mytable` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- Version 2
CREATE TABLE IF NOT EXISTS `mytable` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL,
  `description` text,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- Would result in this:
ALTER TABLE `mytable`
  ADD `description` text;

Edit: this question is related to libraries for MySQL, not tools.

Upvotes: 2

Views: 1407

Answers (3)

Rolf
Rolf

Reputation: 5743

This node module could be useful. It diffs live databases, but then it should be simple to create a live database from an SQL dump.

https://github.com/contra/dbdiff

Upvotes: 0

gbn
gbn

Reputation: 432421

There are a few MySQL comparison tools out there.

Upvotes: 1

Dave Hogan
Dave Hogan

Reputation: 3221

RedGate http://www.red-gate.com/products/sql-development/sql-compare/index-b offer a very good and stable solution to this.

I believe ultimate edition of Visual Studio 2010 can also compare schemas however I'm not sure if it will generate the ALTER scripts for you.

Edit: I just remembered this http://opendbiff.codeplex.com/ too however I didn't have much luck when I last looked at it.

Upvotes: 0

Related Questions