DBIx/Class/Migration/SqliteSandbox.pm

filter: Statementstmt 100% 18 / 18 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 96.0% 24 / 25 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
_generate_filename_for_default_db
1.0
CRAP 1.0
« DBIx/Class/Migration/TargetDirSandboxBuilder.pm ↑ Summary DBIx/Class/Migration/RunScript/Trait/SchemaLoader.pm »
1 package DBIx::Class::Migration::SqliteSandbox;
2  
3 9 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use File::Spec::Functions 'catfile';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 9 with 'DBIx::Class::Migration::Sandbox';
7  
8 13 ▶ sub _generate_filename_for_default_db {
Subroutine _generate_filename_for_default_db: called CC=1 SCAR=0.0
9 13 my ($schema_class) = @_;
10 13 $schema_class =~ s/::/-/g;
11 13 return lc($schema_class);
12 }
13  
14 13 ▶ sub _generate_path_for_default_db {
Subroutine _generate_path_for_default_db: called CC=1 SCAR=0.0
15 13 my ($schema_class, $target_dir) = @_;
16 13 my $filename = _generate_filename_for_default_db($schema_class);
17 13 return catfile($target_dir, "$filename.db");
18 }
19  
20 13 ▶ sub _generate_sqlite_dsn {
Subroutine _generate_sqlite_dsn: called CC=1 SCAR=0.0
21 13 my $db_default_path = _generate_path_for_default_db(@_);
22 13 return "DBI:SQLite:$db_default_path";
23 }
24  
25 13 ▶sub make_sandbox {
Subroutine make_sandbox: called CC=1 SCAR=0.0
Pod undocumented
26 13 my ($self) = @_;
27 13 return _generate_sqlite_dsn($self->schema_class, $self->target_dir), '', '' ;
28 }
29  
30 9 __PACKAGE__->meta->make_immutable;
31  
32 =head1 NAME
33  
34 DBIx::Class::Migration::SqliteSandbox - Autocreate a Sqlite sandbox
35  
36 =head1 SYNOPSIS
37  
38 use DBIx::Class::Migration;
39  
40 my $migration = DBIx::Class::Migration->new(
41 schema_class=>'Local::Schema',
42 db_sandbox_class=>'DBIx::Class::Migration::SqliteSandbox'),
43  
44 $migration->prepare;
45 $migration->install;
46  
47 Please note C<db_sandbox_class> is a lazy built attribute, and it will default
48 to L<DBIx::Class::Migration::SqliteSandbox>.
49  
50 =head1 DESCRIPTION
51  
52 In order to help you jumpstart your database design and deployment, by default
53 we will automatically create a sqlite based file database in your C<target-dir>.
54  
55 This is the default supported option as documented in L<DBIx::Class::Migration>
56 and in L<DBIx::Class::Migration::Tutorial>. L<DBD::SQLite> is useful for your
57 initial development and for when you are trying to build quick prototypes but
58 for production and more serious work I recommend you target a different
59 database. You can use L<MySQL::Sandbox> to make it easy to create local MySQL
60 sandboxes for development, including replication clusters. For a more simple
61 (and limited) approach you can also use L<DBIx::Class::Migration::MySQLSandbox>
62 or L<DBIx::Class::Migration::PgSandbox>.
63  
64 Nothing else is required to install in order to use this default option.
65  
66 Since Sqlite is a simple, single file database that doesn't run persistently
67 we don't create any helper scripts. If you want to access the database directly
68 you can do so with the C<sqlite3> commandline tool which you should get when
69 you get L<DBD::Sqlite>. To access the sandbox database:
70  
71 sqlite3 [target_dir]/[schema_class].db
72  
73 For example, if your C<schema_class> is C<MyApp::Schema> and your sandbox is in
74 the default C<share>:
75  
76 sqlite3 MyApp-Web/share/myapp-schema.db
77  
78 You can also follow the tutorial L<DBIx::Class::Migration::Tutorial> since the
79 bulk of the tutorial uses the sqlite sandbox.
80  
81 =head1 SEE ALSO
82  
83 L<DBIx::Class::Migration>, L<DBD::Sqlite>.
84  
85 =head1 AUTHOR
86  
87 See L<DBIx::Class::Migration> for author information
88  
89 =head1 COPYRIGHT & LICENSE
90  
91 See L<DBIx::Class::Migration> for copyright and license information
92  
93 =cut
94  
« DBIx/Class/Migration/TargetDirSandboxBuilder.pm ↑ Summary DBIx/Class/Migration/RunScript/Trait/SchemaLoader.pm »