Created
August 17, 2011 22:33
-
-
Save btilly/1152817 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/perl | |
use strict; | |
use warnings; | |
use SQL::Translator; | |
use SQL::Translator::Diff; | |
use Data::Dumper; | |
$Data::Dumper::Indent = 1; | |
my $dest_schema = get_schema(q{ | |
CREATE TABLE `foobar` ( | |
`id` int(11) NOT NULL auto_increment, | |
`name` varchar(25) default NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB; | |
}); | |
my $source_schema = get_schema(q{ | |
CREATE TABLE `foobar` ( | |
`id` integer NOT NULL auto_increment, | |
`name` varchar(255) default NULL, | |
PRIMARY KEY (`id`) | |
); | |
}); | |
my $diff = SQL::Translator::Diff::schema_diff( | |
$dest_schema, 'MySQL', $source_schema, 'MySQL'); | |
print $diff; | |
sub get_schema { | |
my $data = shift; | |
my $t = SQL::Translator->new(); | |
$t->parser('MySQL'); | |
my $out = $t->translate(\$data) | |
or die $t->error; | |
return $t->schema(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment