X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=bin%2Fsqlt-diff;h=2bb065a7d809b23f0895749e7721d70af6bcdd12;hb=54360ac93d5401fdc5c84054eec5324bc2f35bfa;hp=c9fb333242cf1473e1d3170927825a2be8c84cf8;hpb=2d4796c746a6ca349ea67795573a258c646c83b3;p=dbsrgits%2FSQL-Translator.git diff --git a/bin/sqlt-diff b/bin/sqlt-diff index c9fb333..2bb065a 100755 --- a/bin/sqlt-diff +++ b/bin/sqlt-diff @@ -2,9 +2,9 @@ # vim: set ft=perl: # ------------------------------------------------------------------- -# $Id: sqlt-diff,v 1.16 2007-03-08 23:11:20 duality72 Exp $ +# $Id$ # ------------------------------------------------------------------- -# Copyright (C) 2002-4 The SQLFairy Authors +# Copyright (C) 2002-2009 The SQLFairy Authors # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -43,11 +43,18 @@ Options: -d|--debug Show debugging info -t|--trace Turn on tracing for Parse::RecDescent - -c|--case-insensitive Compare tables/columns case-insenstiviely + -c|--case-insensitive Compare tables/columns case-insensitively --ignore-index-names Ignore index name differences --ignore-constraint-names Ignore constraint name differences - --output-db This Producer will be used instead of one corresponding to - parser1 to format output for new tables + --mysql_parser_version=<#####> Specify a target MySQL parser version + for dealing with /*! comments + --output-db= This Producer will be used instead of one + corresponding to parser1 to format output + for new tables + --ignore-view-sql Ignore view SQL differences + --ignore-proc-sql Ignore procedure SQL differences + --no-batch-alters Do not clump multile alters to the same table into a + single ALTER TABLE statement where possible. =head1 DESCRIPTION @@ -88,9 +95,10 @@ new index as such: =back -"ALTER/DROP TABLE" and "CREATE INDEX" statements B generated by -the Producer, unfortunately, and may require massaging before being passed to -your target database. +ALTER, CREATE, DROP statements are created by +SQL::Translator::Producer::*, see there for support/problems. + +Currently (v0.0900), only MySQL is supported by this code. =cut @@ -103,10 +111,9 @@ use SQL::Translator; use SQL::Translator::Diff; use SQL::Translator::Schema::Constants; -use vars qw( $VERSION ); -$VERSION = sprintf "%d.%02d", q$Revision: 1.16 $ =~ /(\d+)\.(\d+)/; - -my ( @input, $list, $help, $debug, $trace, $caseopt , $ignore_index_names, $ignore_constraint_names, $output_db ); +my ( @input, $list, $help, $debug, $trace, $caseopt, $ignore_index_names, + $ignore_constraint_names, $output_db, $mysql_parser_version, + $ignore_view_sql, $ignore_proc_sql, $no_batch_alters ); for my $arg ( @ARGV ) { if ( $arg =~ m/^-?-l(ist)?$/ ) { $list = 1; @@ -129,17 +136,37 @@ for my $arg ( @ARGV ) { elsif ( $arg =~ m/^--ignore-constraint-names$/ ) { $ignore_constraint_names = 1; } + elsif ( $arg =~ m/^--mysql-parser-version=(.+)$/ ) { + $mysql_parser_version = $1; + } elsif ( $arg =~ m/^--output-db=(.+)$/ ) { $output_db = $1; } + elsif ( $arg =~ m/^--ignore-view-sql$/ ) { + $ignore_view_sql = 1; + } + elsif ( $arg =~ m/^--ignore-proc-sql$/ ) { + $ignore_proc_sql = 1; + } elsif ( $arg =~ m/^([^=]+)=(.+)$/ ) { push @input, { file => $1, parser => $2 }; } + elsif ( $arg =~ m/^--no-batch-alters$/ ) { + $no_batch_alters = 1; + } else { pod2usage( msg => "Unknown argument '$arg'" ); } } +print STDERR <<'EOM'; +This code is experimental, currently the new code only supports MySQL or +SQLite diffing. To add support for other databases, please patch the relevant +SQL::Translator::Producer:: module. If you need compatibility with the old +sqlt-diff, please use sqlt-diff-old, and look into helping us make this one +work for you +EOM + pod2usage(1) if $help || !@ARGV; pod2usage('Please specify only two schemas to diff') if scalar @input > 2; @@ -162,7 +189,7 @@ my ( $source_schema, $source_db, $target_schema, $target_db ) = map { die "Unable to read file '$file'\n" unless -r $file; die "'$parser' is an invalid parser\n" unless $valid_parsers{ $parser }; - my $t = SQL::Translator->new; + my $t = SQL::Translator->new(parser_args => {mysql_parser_version => $mysql_parser_version}); $t->debug( $debug ); $t->trace( $trace ); $t->parser( $parser ) or die $tr->error; @@ -180,7 +207,10 @@ my $result = SQL::Translator::Diff::schema_diff($source_schema, $source_db, { caseopt => $caseopt, ignore_index_names => $ignore_index_names, ignore_constraint_names => $ignore_constraint_names, + ignore_view_sql => $ignore_view_sql, + ignore_proc_sql => $ignore_proc_sql, output_db => $output_db, + no_batch_alters => $no_batch_alters, debug => $debug, trace => $trace }); if($result)