DBIx-Class-Migration

 view release on metacpan or  search on metacpan

README.mkdn  view on Meta::CPAN

install, I do not require it.  You will need to add it manually to your
`Makefile.PL` or `dist.ini` and manage it yourself.

This feature is experimental and currently does not offer any options, as I
am still determining the best way to meet the need without exceeding the
scope of [DBIx::Class::Migration](https://metacpan.org/pod/DBIx::Class::Migration).  Consider this command a 'freebee' and
please don't depend on it in your custom code.

## install\_if\_needed

If the database is not installed, do so.  Accepts a hash of callbacks or
instructions to perform should installation be needed/

    $migration->install_if_needed(
      on_install => sub {
        my ($schema, $local_migration) = @_;
        DBIx::Class::Migration::Population->new(
          schema=>shift)->populate('all_tables');
      });

The following callbacks / instructions are permitted

- on\_install

    Accepts: Coderef

    Given a coderef, execute it after the database is installed.  The coderef
    gets passed two arguments: `$schema` and `$self` (the current migration
    object).

- default\_fixture\_sets

lib/Catalyst/TraitFor/Model/DBIC/Schema/FromMigration.pm  view on Meta::CPAN

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

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

=head2 install_if_needed

Accepts Bool|HashRef, Optional

If this is a true value, run the L<DBIx::Class::Migration/install_if_needed>
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).

=head1 METHODS

This role exposes the following public methods

=head2 migration

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

lib/DBIx/Class/Migration.pm  view on Meta::CPAN

  $trans->translate
    or _log_die $trans->error;
}

  sub _diagram_default_outfile {
    my $self = shift;
    catfile $self->target_dir, 'db-diagram-v' . $self->dbic_dh->schema_version . '.png';
  }

sub install_if_needed {
  my ($self, %callbacks) = @_;
  if(!$self->dbic_dh->version_storage_is_installed) {
    $self->install;
    if(my $on_install = delete($callbacks{on_install})) {
      $on_install->($self->schema, $self);
    } elsif( my $default_fixture_sets = delete($callbacks{default_fixture_sets})) {
      $self->populate(@$default_fixture_sets);
    }
  }
}

sub install_version_storage {
  my $self = shift;
  if(!$self->dbic_dh->version_storage_is_installed) {
    $self->dbic_dh->install_version_storage;
    $self->dbic_dh->add_database_version({ version => $self->dbic_dh->schema_version });

lib/DBIx/Class/Migration.pm  view on Meta::CPAN

install, I do not require it.  You will need to add it manually to your
C<Makefile.PL> or C<dist.ini> and manage it yourself.

This feature is experimental and currently does not offer any options, as I
am still determining the best way to meet the need without exceeding the
scope of L<DBIx::Class::Migration>.  Consider this command a 'freebee' and
please don't depend on it in your custom code.

=head2 install_if_needed

If the database is not installed, do so.  Accepts a hash of callbacks or
instructions to perform should installation be needed/

    $migration->install_if_needed(
      on_install => sub {
        my ($schema, $local_migration) = @_;
        DBIx::Class::Migration::Population->new(
          schema=>shift)->populate('all_tables');
      });

The following callbacks / instructions are permitted

=over 4

=item on_install

Accepts: Coderef

Given a coderef, execute it after the database is installed.  The coderef
gets passed two arguments: C<$schema> and C<$self> (the current migration
object).



( run in 1.099 second using v1.01-cache-2.11-cpan-9b1e4054eb1 )