Added schema graph generator
This commit is contained in:
parent
a30b05f1c0
commit
957e6a5162
3 changed files with 42 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,3 +7,4 @@ hypnotoad.pid
|
|||
*.swp
|
||||
|
||||
cover_db/
|
||||
schema.png
|
||||
|
|
5
cpanfile
5
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';
|
||||
};
|
||||
|
|
36
script/schema/graph.pl
Executable file
36
script/schema/graph.pl
Executable file
|
@ -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";
|
Reference in a new issue