Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git Diff #1

Open
designermonkey opened this issue May 8, 2014 · 0 comments
Open

Git Diff #1

designermonkey opened this issue May 8, 2014 · 0 comments

Comments

@designermonkey
Copy link
Owner

I want to be able to diff commits using the following syntax

git diff <latest-commit> <earlier-commit>

and extract changes as MySQL queries.

Running a diff like this would create syntax like the following (for two commits to change the same table)

@@ -24,6 +24,8 @@ DROP TABLE IF EXISTS `test`;
 /*!40101 SET character_set_client = utf8 */;
 CREATE TABLE `test` (
   `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `new_column` varchar(200) DEFAULT NULL,
+  `another` int(200) NOT NULL,
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 /*!40101 SET character_set_client = @saved_cs_client */;

or

@@ -24,8 +24,6 @@ DROP TABLE IF EXISTS `test`;
 /*!40101 SET character_set_client = utf8 */;
 CREATE TABLE `test` (
   `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `new_column` varchar(200) DEFAULT NULL,
-  `another` int(200) NOT NULL,
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 /*!40101 SET character_set_client = @saved_cs_client */;

For a simple change like this, the resulting query should be

ALTER TABLE `test` ADD COLUMN `new_column` varchar(200) DEFAULT NULL AFTER `id`;
ALTER TABLE `test` ADD COLUMN `another` int(200) NOT NULL AFTER `new_column`;

or

ALTER TABLE `test` DROP COLUMN `new_column`;
ALTER TABLE `test` DROP COLUMN `another`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant