DEV Community

Auto-generate a Database Schema Diagram

Mitch Jackson on June 02, 2018

Generate a Live Database Schema Diagram for your Catalyst Application When building a web application, I always create a URL endpoint ...
Collapse
 
fluffy profile image
fluffy

Oh wow, this is perfect! I recently started a job in which a primary role is maintaining and extending a rather large Catalyst app and I have never used Catalyst before. I'm also about ten years out-of-date on my Perl knowledge. So, every little bit helps. :)

Collapse
 
mitchjacksontech profile image
Mitch Jackson

Congrats on the new job, thanks for letting me know this was helpful.

Collapse
 
exadra37 profile image
Paulo Renato • Edited

A production system should not have this endpoint at all. This is bad as a security practice and means that your automation as failed or does not exist at all.

Please if you really need it just expose it from the command line.

NOTE: having ssh access to a production system also means failure in you automation pipeline.

Collapse
 
mitchjacksontech profile image
Mitch Jackson

You raise a good point: this feature is obviously to support development, not for production

Collapse
 
thorstenhirsch profile image
Thorsten Hirsch

What's :Local and :Args(0)?

Collapse
 
mitchjacksontech profile image
Mitch Jackson

These function attributes are particular to the Catalyst MVC Framework.

You would include this function in a Catalyst::Controller package. In this case, you may choose YourApp::Controller::Debug as the controller name.

Catalyst will map this dbdiagram action to an application URL, as specified by these function attributes.

With :Local, this action URL part will be the function name, relative to the controller name. http://yourapp/debug/dbdiagram

A Catalyst action can receive function arguments as parts of the request URL. :Args(0) specifies this action will receive 0 arguments this way. This makes Pretty URL's easy. dbdiagram might accept a database name, and table name as arguments. This action would respond to the URL: http://yourapp/debug/dbdiagram/database_name/table_name.

sub dbdiagram :Local :Args(2) {
    my ($self, $c, $db_name, $table_name) = @_;

    # ...
}