Mojolicious-Plugin-DbicSchemaViewer

Viewer for DBIx::Class schema definitions


License
Artistic-1.0-Perl

Documentation

NAME

Mojolicious::Plugin::DbicSchemaViewer - Viewer for DBIx::Class schema definitions

Requires Perl 5.20+ Travis status Distribution kwalitee CPAN Testers result coverage 59.0%

VERSION

Version 0.0200, released 2016-09-20.

SYNOPSIS

$self->plugin(DbicSchemaViewer => {
    schema => Your::Schema->connect(...),
});

DESCRIPTION

This plugin is a definition viewer for DBIx::Class schemas. It currently offers two different views on the schema:

  • It lists all result sources with column definitions and and their relationships in table form.
  • It uses DBIx::Class::Visualizer to generate an entity-relationship model.

Configuration

The following settings are available. It is recommended to use either "router" or "condition" to place the viewer behind some kind of authorization check.

allowed_schemas

An optional array reference consisting of schema classes. If set, only these classes are available for viewing.

If not set, all findable schema classes can be viewed.

url

Optional.

By default, the viewer is located at /dbic-schema-viewer.

$self->plugin(DbicSchemaViewer => {
    url => '/the-schema',
    schema => Your::Schema->connect(...),
});

The viewer is instead located at /the-schema.

Note that the CSS and Javascript files are served under /dbic-schema-viewer regardless of this setting.

router

Optional. Can not be used together with "condition".

Use this when you which to place the viewer behind an under route:

my $secure = $app->routes->under('/secure' => sub {
    my $c = shift;
    return defined $c->session('logged_in') ? 1 : 0;
});

$self->plugin(DbicSchemaViewer => {
    router => $secure,
    schema => Your::Schema->connect(...),
});

Now the viewer is located at /secure/dbic-schema-viewer (if the check is successful).

condition

Optional. Can not be used together with "router".

Use this when you have a named condition you which to place the viewer behind:

$self->routes->add_condition(random => sub { return !int rand 4 });

$self->plugin(DbicSchemaViewer => {
    condition => 'random',
    schema => Your::Schema->connect(...),
});

DEMO

There is a demo available at http://dsv.code301.com/MadeUp::Book::Schema. Don't miss the help page for instructions.

SEE ALSO

SOURCE

https://github.com/Csson/p5-Mojolicious-Plugin-DbicSchemaViewer

HOMEPAGE

https://metacpan.org/release/Mojolicious-Plugin-DbicSchemaViewer

AUTHOR

Erik Carlsson info@code301.com

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Erik Carlsson.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.