Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
Catalyst::TraitFor::MCUseryContributedrPerldDocumentationNAME
       Catalyst::TraitFor::Model::DBIC::Schema::FromMigration -	Use your DB
       Sandbox to run Catalyst

SYNOPSIS
       Use the trait in	your Catalyst configuration:

	   'Model::Schema' => {
	     traits => ['FromMigration'],
	     schema_class => 'MusicBase::Schema',
	     extra_migration_args => {
	       db_sandbox_class	=> 'DBIx::Class::Migration::MySQLSandbox'},
	     install_if_needed => {
	       on_install => sub {
		 my ($schema, $migration) = @_;
		 $migration->populate('all_tables')}},
	     },

DESCRIPTION
       If you are in development and using a database sandbox auto created and
       managed for you with DBIx::Class::Migration, this is a trait to make it
       easy to hook that sandbox up to your Catalyst application.  The
       following are roughly the same:

	   package MusicBase::Web::Model::Schema;

	   use Moose;
	   extends 'Catalyst::Model::DBIC::Schema';

	   __PACKAGE__->config
	   (
	       schema_class => 'MusicBase::Schema',
	       connect_info => {
		 dsn =>	'DBI:SQLite:__path_to(share,musicbase-schema.db)__',
		 user => '',
		 password => '',
	       },
	   )

	   __PACKAGE__->meta->make_immutable;

       And using the trait:

	   package MusicBase::Web::Model::Schema;

	   use Moose;
	   extends 'Catalyst::Model::DBIC::Schema';

	   __PACKAGE__->config
	   (
	       traits => ['FromMigration'],
	       schema_class => 'MusicBase::Schema',
	       extra_migration_args => \%args,
	       install_if_needed => {
		 default_fixture_sets => ['all_tables']},
	   )

	   __PACKAGE__->meta->make_immutable;

       The biggest reasons to use this trait would be it makes it harder to
       connect the wrong database and it gives you some	easy helpers for
       automatic database installation and fixture population (as you can see
       in the above example).

CONFIG PARAMETERS
       This trait uses the following configuration parameters:

   extra_migration_args
       Accepts:	Hashref, Optional

       A hashref of init arguments that	you'd pass to the "new"	method of
       DBIx::Class::Migration.	"schema_class" is inferred from	the existing
       config parameter, so you	don't need to pass that	one.  Other arguments
       of use could be "db_sandbox_class".

	   extra_migration_args	=> {
	     db_sandbox_class => 'DBIx::Class::Migration::MySQLSandbox'},

       For example would use a MySQL development sandbox instead of the
       default SQLite.

   install_if_needed
       Accepts Bool|HashRef, Optional

       If this is a true value,	run the	"install_if_needed" in
       DBIx::Class::Migration method.  If the value is a Hashref, we will
       assume it is a hashref of callbacks as documented, and use it as	an
       argument	(after de-reffing it).

METHODS
       This role exposes the following public methods

   migration
       Returns the DBIx::Class::Migration object created to assist setting up
       and managing your database.

   do_install_if_needed
       Installs	a database and possibly	do some	data population, if one	does
       not yet exist.

SEE ALSO
       Catalyst::Model::DBIC::Schema, Catalyst

AUTHOR
       See DBIx::Class::Migration for author information

COPYRIGHT & LICENSE
       See DBIx::Class::Migration for copyright	and license information

perl v5.32.0	     Catalyst::TraitFor::Model::DBIC::Schema::FromMigration(3)

NAME | SYNOPSIS | DESCRIPTION | CONFIG PARAMETERS | METHODS | SEE ALSO | AUTHOR | COPYRIGHT & LICENSE

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=Catalyst::TraitFor::Model::DBIC::Schema::FromMigration&sektion=3&manpath=FreeBSD+12.2-RELEASE+and+Ports>

home | help