FabForce::DBDesigner4::DBIC - create DBIC scheme for DBDesigner4 xml file
version 0.14
use FabForce::DBDesigner4::DBIC; my $foo = FabForce::DBDesigner4::DBIC->new(); $foo->output_path( $some_path ); $foo->namespace( 'MyApp::DB' ); $foo->version_add( 0.01 ); $foo->create_schema( $xml_document );
creates a new object of FabForce::DBDesigner4::DBIC. You can pass some parameters to new (all parameters are optional)
my $foo = FabForce::DBDesigner4::DBIC->new( output_path => '/path/to/dir', input_file => '/path/to/dbdesigner.file', namespace => 'MyApp::Database', version_add => 0.001, schema_name => 'MySchema', column_details => 1, use_fake_dbic => 1, # default 0. );
use_fake_dbic is helpful when DBIx::Class is not installed on the machine where you use this module.
use_fake_dbic
DBIx::Class
sets / gets the output path for the scheme
$foo->output_path( '/any/directory' ); print $foo->output_path;
sets / gets the name of the DBDesigner file (XML format)
$foo->input_file( 'dbdesigner.xml' ); print $foo->input_file;
If enabled, the column definitions are more detailed. Default: disabled.
$foo->column_details( 1 );
Standard (excerpt from Result classes):
__PACKAGE__->add_columns( qw/ cert_id register_nr state );
With enabled column details:
__PACKAGE__->add_columns( cert_id => { data_type => 'integer', is_nullable => 0, is_auto_increment => 1, }, register_nr => { data_type => 'integer', is_nullable => 0, }, state => { data_type => 'varchar', size => 1, is_nullable => 0, default_value => 'done', }, );
This is useful when you use DBIx::Class::DeploymentHandler to deploy the columns correctly.
The files should be versioned (e.g. to deploy the DB via DBIx::Class::DeploymentHandler). On the first run the version is set to "0.01". When the schema file already exists, the version is increased by the value of version_add (default: 0.01)
DBIx::Class::DeploymentHandler
version_add
$foo->version_add( 0.001 );
creates all the files that are needed to work with DBIx::Class schema:
The main module that loads all classes and one class per table. If you haven't specified an input file, the module will croak.
You can specify the input file either with input_file or as an parameter for create_schema
$foo->input_file( 'dbdesigner.xml' ); $foo->create_schema; # or $foo->create_schema( 'dbdesigner.xml' );
create_scheme is an alias for create_schema for compatibility reasons
create_scheme
create_schema
sets a new name for the schema. By default on of these names is used:
DBIC_Scheme Database DBIC MyScheme MyDatabase DBIxClass_Scheme $dbic->schema_name( 'MyNewSchema' );
sets / gets the name of the namespace. If you set the namespace to 'Test' and you have a table named 'MyTable', the main module is named 'Test::DBIC_Scheme' and the class for 'MyTable' is named 'Test::DBIC_Scheme::MyTable'
$foo->namespace( 'MyApp::DB' );
In relationships the accessor for the objects of the "other" table shouldn't have the name of the column. Otherwise it is very clumsy to get the orginial value of this table.
$foo->prefix( 'belongs_to' => 'fk_' ); $foo->prefix( 'has_many' => 'has_' );
creates (col1 is the column name of the foreign key)
__PACKAGE__->belongs_to( 'fk_col1' => 'OtherTable', {'foreign.col1' => 'self.col1' } );
returns the FabForce::DBDesigner4 object.
FabForce::DBDesigner4
Please report any bugs or feature requests to bug-fabforce-dbdesigner4-dbic at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=FabForce::DBDesigner4::DBIC. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-fabforce-dbdesigner4-dbic at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc FabForce::DBDesigner4::DBIC
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/FabForce::DBDesigner4::DBIC
CPAN Ratings
http://cpanratings.perl.org/d/FabForce::DBDesigner4::DBIC
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=FabForce::DBDesigner4::DBIC
Search CPAN
http://search.cpan.org/dist/FabForce::DBDesigner4::DBIC
Renee Baecker <module@renee-baecker.de>
This software is Copyright (c) 2013 by Renee Baecker.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install FabForce::DBDesigner4::DBIC, copy and paste the appropriate command in to your terminal.
cpanm
cpanm FabForce::DBDesigner4::DBIC
CPAN shell
perl -MCPAN -e shell install FabForce::DBDesigner4::DBIC
For more information on module installation, please visit the detailed CPAN module installation guide.