« DBIx/Class/Migration/RunScript/Trait/TargetPath.pm
↑ Summary
DBIx/Class/Migration/TempDirBuilder.pm »
| 1 | package DBIx::Class::Migration::SchemaLoader; | ||||||||||
| 2 | |||||||||||
| 3 | 9 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 9 | ▶ | use DBIx::Class::Schema::Loader; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 9 | has schema => (is=>'ro', required=>1); | |||||||||
| 7 | |||||||||||
| 8 | 22 | ▶ | sub opts { | ||||||||
|
Subroutine
opts: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||
| 9 | naming => { ALL => 'v7'}, | ||||||||||
| 10 | use_namespaces => 1, | ||||||||||
| 11 | 22 | ▶ | debug => ($ENV{DBIC_MIGRATION_DEBUG}||0); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 12 | } | ||||||||||
| 13 | |||||||||||
| 14 | 9 | ▶ | sub _merge_opts { opts(), @_ }; | ||||||||
|
Subroutine
_merge_opts: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 9 | ▶ | sub _rearrange_connect_info { | ||||||||
|
Subroutine
_rearrange_connect_info: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 9 | my ($storage) = @_; | |||||||||
| 18 | 9 | my $nci = $storage->_normalize_connect_info( | |||||||||
| 19 | $storage->connect_info); | ||||||||||
| 20 | return ( | ||||||||||
| 21 | 9 | ▶ | dbh_maker => sub { $storage->dbh }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 0 | map %{$nci->{$_}}, grep { $_ ne 'arguments' } keys %$nci, | |||||||||
| 23 | ); | ||||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 9 | ▶ | sub _make_schema_at { | ||||||||
|
Subroutine
_make_schema_at: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 9 | my ($self, $name, %extra_opts) = @_; | |||||||||
| 28 | 9 | my $schema = $self->schema->clone; | |||||||||
| 29 | 9 | DBIx::Class::Schema::Loader::make_schema_at | |||||||||
| 30 | $name, {_merge_opts(%extra_opts)}, [{_rearrange_connect_info($schema->storage)}]; | ||||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 22 | ▶ | sub _next_cnt { our $_cnt++ } | ||||||||
|
Subroutine
_next_cnt: called CC=1 SCAR=0.0
| |||||||||||
| 34 | 22 | ▶ | sub _as_unique_ns { $_[0] . _next_cnt() } | ||||||||
|
Subroutine
_as_unique_ns: called CC=1 SCAR=0.0
| |||||||||||
| 35 | |||||||||||
| 36 | 9 | ▶ | sub schema_from_database { | ||||||||
|
Subroutine
schema_from_database: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 37 | 9 | my ($self, $ns, %extra_opts) = @_; | |||||||||
| 38 | 9 | $self->_make_schema_at(_as_unique_ns($ns), %extra_opts); | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | sub generate_dump { | ||||||||
|
Subroutine
generate_dump: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 42 | 0 | my ($self, $ns, $dump_dir) = @_; | |||||||||
| 43 | 0 | $self->_make_schema_at( | |||||||||
| 44 | $ns, | ||||||||||
| 45 | dump_directory => $dump_dir, | ||||||||||
| 46 | exclude => qr/dbix_class_deploymenthandler_versions/, | ||||||||||
| 47 | ); | ||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 9 | 1; | |||||||||
| 51 | |||||||||||
| 52 | =head1 NAME | ||||||||||
| 53 | |||||||||||
| 54 | DBIx::Class::Migration::SchemaLoader - Schema Loader Factory | ||||||||||
| 55 | |||||||||||
| 56 | =head1 SYNOPSIS | ||||||||||
| 57 | |||||||||||
| 58 | For internal use only | ||||||||||
| 59 | |||||||||||
| 60 | =head1 DESCRIPTION | ||||||||||
| 61 | |||||||||||
| 62 | Often when running migrations we need to auto generate a L<DBIx::Class::Schema> | ||||||||||
| 63 | directly from the existing database. This class performs that function. | ||||||||||
| 64 | |||||||||||
| 65 | There are no end user bits here, but we do expose an C<%ENV> variable which | ||||||||||
| 66 | turns on L<DBIx::Class::Schema::Loader> debugging mode. This can be useful | ||||||||||
| 67 | since the generated schema will get dumped to STDOUT, helping you sort out | ||||||||||
| 68 | any confusion about your classes and relationships. | ||||||||||
| 69 | |||||||||||
| 70 | export DBIC_MIGRATION_DEBUG=1 | ||||||||||
| 71 | |||||||||||
| 72 | Or run it one time: | ||||||||||
| 73 | |||||||||||
| 74 | DBIC_MIGRATION_DEBUG=1 dbic-migration [command] | ||||||||||
| 75 | |||||||||||
| 76 | =head1 SEE ALSO | ||||||||||
| 77 | |||||||||||
| 78 | L<DBIx::Class::Migration>, L<DBIx::Class::Schema::Loader>. | ||||||||||
| 79 | |||||||||||
| 80 | =head1 AUTHOR | ||||||||||
| 81 | |||||||||||
| 82 | See L<DBIx::Class::Migration> for author information | ||||||||||
| 83 | |||||||||||
| 84 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 85 | |||||||||||
| 86 | See L<DBIx::Class::Migration> for copyright and license information | ||||||||||
| 87 | |||||||||||
| 88 | =cut | ||||||||||
| 89 | |||||||||||
| 90 | |||||||||||