logo
Free, Micro AI Code Reviews That Run on Git Commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, Micro AI Code Reviews That Run on Git Commit | Product Hunt git-lrc - Free, Micro AI Code Reviews That Run on Git Commit | Product Hunt

Test::DBIx::Class::FixtureCommand::Populate - Install fixtures using Populate

Author

       John Napiorkowski "<jjnapiork@cpan.org>"

Description

       This uses the "populate" in DBIx::Class::Schema method to install fixture data.  Expects an hash of
       "Source => [\@fields, \@rows]".  Please see the 'populate' method for more information.  Examples:

               ->install_fixtures(
                       Person => [
                               ['name', 'age'],
                               ['john', 40],
                               ['vincent', 15],
                       ],
                       Job => [
                               [title => 'description'],
                               [programmer => 'Who wrote the code'],
                               [marketer => 'Who sold the code'],
                       ],
               );

       You may include as many Sources as you like, and even the same one more than once.

       For additional flexibility with various configuration formats, we accept three variations of the incoming
       arguments:

               ## Array of HashRefs
               ->install_fixtures(
                       {Person => [
                               ['name', 'age'],
                               ['john', 40],
                               ['vincent', 15],
                       ]},
                       {Job => [
                               [title => 'description'],
                               [programmer => 'Who wrote the code'],
                               [marketer => 'Who sold the code'],
                       ]},
               );

               ## ArrayRef
               ->install_fixtures([
                       Person => [
                               ['name', 'age'],
                               ['john', 40],
                               ['vincent', 15],
                       ],
                       Job => [
                               [title => 'description'],
                               [programmer => 'Who wrote the code'],
                               [marketer => 'Who sold the code'],
                       ],
               ]);

               ## ArrayRef of HashRefs
               ->install_fixtures([
                       {Person => [
                               ['name', 'age'],
                               ['john', 40],
                               ['vincent', 15],
                       ]},
                       {Job => [
                               [title => 'description'],
                               [programmer => 'Who wrote the code'],
                               [marketer => 'Who sold the code'],
                       ]},
               ]);

       This should allow you to model your fixtures in your configuration format of choice without a lot of
       trouble.

Methods

       This class defines the following methods

   install_fixtures
       Takes an Array or ArrayRef of arguments and installs them into your target database.  Returns an array of
       hashrefs, where each hashref is a {$source => @rows} pair.

Name

       Test::DBIx::Class::FixtureCommand::Populate - Install fixtures using Populate

Synopsis

               my $command = Test::DBIx::Class::FixtureComand::Populate->new(schema=>$schema);
               $command->install_fixtures($fixtures);

See Also