Catalys...gration(3)

πŸ“¦ version 0.075, in opensuse-leap 16.0

πŸ’– 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

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