Catalyst-Model-DBIC-Schema
view release on metacpan or search on metacpan
lib/Catalyst/Helper/Model/DBIC/Schema.pm view on Meta::CPAN
package Catalyst::Helper::Model::DBIC::Schema;
use namespace::autoclean;
use Moose;
no warnings 'uninitialized';
our $VERSION = '0.66';
$VERSION =~ tr/_//d;
use Carp;
use Tie::IxHash ();
use Data::Dumper ();
use List::Util 'first';
use MooseX::Types::Moose qw/Str HashRef Bool ArrayRef/;
use Catalyst::Model::DBIC::Schema::Types 'CreateOption';
use List::MoreUtils 'firstidx';
use Scalar::Util 'looks_like_number';
use File::Find 'finddepth';
use Try::Tiny;
use Cwd 'getcwd';
use Module::Runtime 'use_module';
=head1 NAME
Catalyst::Helper::Model::DBIC::Schema - Helper for DBIC Schema Models
=head1 SYNOPSIS
script/create.pl model CatalystModelName DBIC::Schema MyApp::SchemaClass \
[ create=dynamic | create=static ] [ traits=trait1,trait2... ] \
[ Schema::Loader opts ] [ dsn user pass ] \
[ other connect_info args ]
=head1 DESCRIPTION
Helper for the DBIC Schema Models.
=head2 Arguments:
C<CatalystModelName> is the short name for the Catalyst Model class
being generated (i.e. callable with C<$c-E<gt>model('CatalystModelName')>).
C<MyApp::SchemaClass> is the fully qualified classname of your Schema,
which might or might not yet exist. Note that you should have a good
reason to create this under a new global namespace, otherwise use an
existing top level namespace for your schema class.
C<create=dynamic> instructs this Helper to generate the named Schema
class for you, basing it on L<DBIx::Class::Schema::Loader> (which
means the table information will always be dynamically loaded at
runtime from the database).
C<create=static> instructs this Helper to generate the named Schema
class for you, using L<DBIx::Class::Schema::Loader> in "one shot"
mode to create a standard, manually-defined L<DBIx::Class::Schema>
setup, based on what the Loader sees in your database at this moment.
A Schema/Model pair generated this way will not require
L<DBIx::Class::Schema::Loader> at runtime, and will not automatically
adapt itself to changes in your database structure. You can edit
the generated classes by hand to refine them.
C<traits> is the list of traits to apply to the model, see
L<Catalyst::Model::DBIC::Schema> for details.
C<Schema::Loader opts> are documented in L<DBIx::Class::Schema::Loader::Base>
and some examples are given in L</TYPICAL EXAMPLES> below.
C<connect_info> arguments are the same as what L<DBIx::Class::Schema/connect>
expects, and are storage_type-specific. They are documented in
L<DBIx::Class::Storage::DBI/connect_info>. For DBI-based storage, these
arguments are the dsn, username, password, and connect options, respectively.
These are optional for existing Schemas, but required if you use either of the
C<create=> options.
username and password can be omitted for C<SQLite> dsns.
Use of either of the C<create=> options requires L<DBIx::Class::Schema::Loader>.
=head1 TYPICAL EXAMPLES
( run in 1.750 second using v1.01-cache-2.11-cpan-39bf76dae61 )