From: Ken Youens-Clark Date: Sat, 13 May 2006 01:21:21 +0000 (+0000) Subject: Commiting. X-Git-Tag: v0.11008~443 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e7ca845afff421e4c89e6d42ff740c9343d5fe27;p=dbsrgits%2FSQL-Translator.git Commiting. --- diff --git a/lib/SQL/Translator/Schema.pm b/lib/SQL/Translator/Schema.pm index 5ef5257..0c44bd8 100644 --- a/lib/SQL/Translator/Schema.pm +++ b/lib/SQL/Translator/Schema.pm @@ -3,7 +3,7 @@ package SQL::Translator::Schema; # vim: sw=4: ts=4: # ---------------------------------------------------------------------- -# $Id: Schema.pm,v 1.24 2005-06-27 22:02:50 duality72 Exp $ +# $Id: Schema.pm,v 1.25 2006-05-13 01:21:21 kycl4rk Exp $ # ---------------------------------------------------------------------- # Copyright (C) 2002-4 SQLFairy Authors # @@ -60,7 +60,7 @@ use SQL::Translator::Utils 'parse_list_arg'; use base 'SQL::Translator::Schema::Object'; use vars qw[ $VERSION $TABLE_ORDER $VIEW_ORDER $TRIGGER_ORDER $PROC_ORDER ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.24 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.25 $ =~ /(\d+)\.(\d+)/; __PACKAGE__->_attributes(qw/name database translator/); @@ -81,6 +81,36 @@ Returns the schema as an L object. } # ---------------------------------------------------------------------- +sub as_graph_pm { + +=pod + +=head2 as_grap_pmh + +Returns a Graph::Directed object with the table names for nodes. + +=cut + + my $self = shift; + my $g = Graph::Directed->new; + + for my $table ( $self->get_tables ) { + my $tname = $table->name; + $g->add_vertex( $tname ); + + for my $field ( $table->get_fields ) { + if ( $field->is_foreign_key ) { + my $fktable = $field->foreign_key_reference->reference_table; + + $g->add_edge( $fktable, $tname ); + } + } + } + + return $g; +} + +# ---------------------------------------------------------------------- sub add_table { =pod