Catalys...gration(3)
π NAME π
okay bestie, welcome to the Catalys...gration(3) page β it's a User Contributed Perl Documentation page for Catalyst::TraitFor::Model::DBIC::Schema::FromMigration, and the description is Use your DB Sandbox to run Catalyst. periodt. no cap. π
β¨ 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 π¦
okay so picture this: you're 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). the way it just handles all that for you is iconic π«Ά
πΈ 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). iykyk β¨
π METHODS π
This role exposes the following public methods
π
migration π
Returns the DBIx::Class::Migration object created to assist setting up and managing your database. slay.
π
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
that's the whole vibe check, bestie β signing off from Catalys...gration(3) with perl v5.42.0, dated 2020-06-03 π
β¨ fr fr.
π¦ where this page comes from
- opensuse-leap 16.0: perl-DBIx-Class-Migration 0.075-bp160.1.10 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms