diff --git a/.gitignore b/.gitignore index 41ff8f3..b7fbab8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ hypnotoad.pid *.swp cover_db/ +schema.png diff --git a/cpanfile b/cpanfile index 6e21422..e38cdc8 100644 --- a/cpanfile +++ b/cpanfile @@ -21,3 +21,8 @@ requires 'MooX::Options::Actions'; requires 'Module::Runtime'; requires 'DBIx::Class::DeploymentHandler'; requires 'DBIx::Class::Fixtures'; + +on 'schema-graph' => sub { + requires 'GraphViz'; + requires 'SQL::Translator'; +}; diff --git a/script/schema/graph.pl b/script/schema/graph.pl new file mode 100755 index 0000000..f51921c --- /dev/null +++ b/script/schema/graph.pl @@ -0,0 +1,36 @@ +#! /usr/bin/env perl +use strict; +use warnings; + +use feature "say"; + +use FindBin qw/ $Bin /; +use lib "$Bin/../../lib"; + +use SQL::Translator; +use Pear::LocalLoop::Schema; + +say "Setting up Translator and Schema"; + +my $schema = Pear::LocalLoop::Schema->connect; +my $tr = SQL::Translator->new( + from => "SQL::Translator::Parser::DBIx::Class", + to => 'GraphViz', + debug => 1, + trace => 1, + producer_args => { + out_file => "$Bin/../../schema.png", + output_type => 'png', + width => 0, + height => 0, + show_constraints => 1, + show_datatypes => 1, + show_sizes => 1, + }, +); + +say "Translating Schema to image"; + +$tr->translate( data => $schema ); + +say "Finished";