use SQL::Translator;
- my $trans = new SQL::Translator(
+ my $trans = SQL::Translator->new(
from => 'MySQL', # or your db of choice
- to => 'GraphViz',
+ to => 'GraphViz',
producer_args => {
- out_file => 'schema.png',
- bgcolor => 'lightgoldenrodyellow',
+ out_file => 'schema.png',
+ bgcolor => 'lightgoldenrodyellow',
show_constraints => 1,
- show_datatypes => 1,
- show_sizes => 1
+ show_datatypes => 1,
+ show_sizes => 1
}
) or die SQL::Translator->error;
=item * cluster
-POD PENDING
+Clustering of tables allows you to group and box tables according to
+function or domain or whatever criteria you choose. The syntax for
+clustering tables is:
+
+ cluster => 'cluster1=table1,table2;cluster2=table3,table4'
+
+Or pass it as an arrayref like so:
+
+ cluster => [ 'cluster1=table1,table2', 'cluster2=table3,table4' ]
+
+Or like so:
+
+ cluster => [
+ { name => 'cluster1', tables => [ 'table1', 'table2' ] },
+ { name => 'cluster2', tables => [ 'table3', 'table4' ] },
+ ]
=item * out_file
# translate legacy {node|edge|graph}attrs to just {node|edge|graph}
for my $argtype (qw/node edge graph/) {
my $old_arg = $argtype . 'attrs';
- $args->{$argtype} = {
- map { %{ $_ || {} } }
- ( delete $args->{$old_arg}, $args->{$argtype} )
- };
+
+ my %arglist = (map
+ { %{ $_ || {} } }
+ ( delete $args->{$old_arg}, delete $args->{$argtype} )
+ );
+
+ $args->{$argtype} = \%arglist if keys %arglist;
}
# explode font settings
}
}
-
#
# Create a blank GraphViz object and see if we can produce the output type.
#
$node_args->{cluster} = $cluster_name;
}
- $gv->add_node ($table_name, %$node_args);
+ $gv->add_node(qq["$table_name"], %$node_args);
debug("Processing table '$table_name'");
next if $i == $j;
my $table2 = $tables[ $j ];
next if $done{ $table1 }{ $table2 };
+ debug("Adding edge '$table2' -> '$table1'");
$gv->add_edge(
- $table2,
- $table1,
+ qq["$table2"],
+ qq["$table1"],
arrowhead => $optional_constraints{$bi} ? 'empty' : 'normal',
);
$done{ $table1 }{ $table2 } = 1;