From: Ken Youens-Clark Date: Thu, 5 Aug 2004 15:41:46 +0000 (+0000) Subject: Removed some old code, make table type "InnoDB" if there's a FK constraint. X-Git-Tag: v0.06~19 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d2d944cc90f72912a3a29643110fb98a64e230b2;p=dbsrgits%2FSQL-Translator.git Removed some old code, make table type "InnoDB" if there's a FK constraint. --- diff --git a/lib/SQL/Translator/Producer/MySQL.pm b/lib/SQL/Translator/Producer/MySQL.pm index c5613d3..8b2c45d 100644 --- a/lib/SQL/Translator/Producer/MySQL.pm +++ b/lib/SQL/Translator/Producer/MySQL.pm @@ -1,7 +1,7 @@ package SQL::Translator::Producer::MySQL; # ------------------------------------------------------------------- -# $Id: MySQL.pm,v 1.33 2004-04-19 16:38:37 kycl4rk Exp $ +# $Id: MySQL.pm,v 1.34 2004-08-05 15:41:46 kycl4rk Exp $ # ------------------------------------------------------------------- # Copyright (C) 2002-4 SQLFairy Authors # @@ -44,7 +44,7 @@ for fields, etc.). use strict; use vars qw[ $VERSION $DEBUG ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.33 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.34 $ =~ /(\d+)\.(\d+)/; $DEBUG = 0 unless defined $DEBUG; use Data::Dumper; @@ -201,6 +201,7 @@ sub produce { # Constraints -- need to handle more than just FK. -ky # my @constraint_defs; + my $has_fk; for my $c ( $table->get_constraints ) { my @fields = $c->fields or next; @@ -213,6 +214,7 @@ sub produce { 'UNIQUE (' . join(', ', @fields). ')'; } elsif ( $c->type eq FOREIGN_KEY ) { + $has_fk = 1; my $def = join(' ', map { $_ || () } 'FOREIGN KEY', $c->name ); @@ -250,11 +252,9 @@ sub produce { # Footer # $create .= "\n)"; -# while ( -# my ( $key, $val ) = each %{ $table->options } -# ) { -# $create .= " $key=$val" -# } + if ( $has_fk ) { + $create .= " Type=InnoDB"; + } $create .= ";\n\n"; }