X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FDeploymentHandler%2FManual%2FIntro.pod;h=1148b53efe145b90c9945fc60270eb696d2f8b04;hb=3d416c8f66d964a153fccd0c3fc45d03b148879f;hp=58d3d3b31cdb047b7684ced84df2dfef5cfa6cb6;hpb=ee8b35488f1450fe7e6e5a1cc3d995ef6eb65141;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git diff --git a/lib/DBIx/Class/DeploymentHandler/Manual/Intro.pod b/lib/DBIx/Class/DeploymentHandler/Manual/Intro.pod index 58d3d3b..1148b53 100644 --- a/lib/DBIx/Class/DeploymentHandler/Manual/Intro.pod +++ b/lib/DBIx/Class/DeploymentHandler/Manual/Intro.pod @@ -36,7 +36,12 @@ or if you are using a newer Perl you can use the prettier syntax: By default DBIx::Class::DeploymentHandler only uses integers for versions, this makes versioning much simpler for figuring out what version is next -(or previous.) +(or previous.) However, if you are using decimal numbers for versioning, +you will need to create a separate DeploymentHandler class, as per +L, and +set the VersionHandler class_name from Monotonic to ExplicitVersions or +DatabaseToSchemaVersions, as these handle version numbers as strings instead +of integers. =head1 install.pl @@ -44,20 +49,32 @@ Our first script, C reads our schema file and creates the tables in the database. #!/usr/bin/env perl + use strict; use warnings; use aliased 'DBIx::Class::DeploymentHandler' => 'DH'; + use Getopt::Long; use FindBin; use lib "$FindBin::Bin/../lib"; use MyDatabase::Main; - my $schema = MyDatabase::Main->connect('dbi:SQLite:mydb'); - my $dh = DH->new({ - schema => $schema, - script_directory => "$FindBin::Bin/dbicdh", - databases => 'SQLite', - sql_translator_args => { add_drop_table => 0 }, - }); + my $force_overwrite = 0; + + unless ( GetOptions( 'force_overwrite!' => \$force_overwrite ) ) { + die "Invalid options"; + } + + my $schema = MyDatabase::Main->connect('dbi:SQLite:mydb.db'); + + my $dh = DH->new( + { + schema => $schema, + script_directory => "$FindBin::Bin/../dbicdh", + databases => 'SQLite', + sql_translator_args => { add_drop_table => 0 }, + force_overwrite => $force_overwrite, + } + ); $dh->prepare_install; $dh->install; @@ -76,6 +93,10 @@ Running C should create the following: `-- 1 `-- 001-auto.yml +You may wish to turn on L +before running this script by setting the environment variable C to +C<1>. + =head3 001-auto.sql DBIx::Class::DeploymentHandler automatically generates SQL from our schema @@ -90,17 +111,17 @@ translated into the sql. To truly take advantage of all DBIx::Class::DeploymentHandler offers, you should probably be using it for population. To do that all you need to do -is create a file called C: - - sub { - my $schema = shift; - $schema->resultset('User')->populate([ - ['name'], - ['Marillion'], - ['The Moutain Goats'], - ['Ladyhawke'], - ]); - }; +is create a file called C: + + sub { + my $schema = shift; + $schema->resultset('Artist')->populate([ + ['artistid', 'name'], + [1, 'Marillion'], + [2, 'The Moutain Goats'], + [3, 'Ladyhawke'], + ]); + }; =head1 Upgrading @@ -136,7 +157,7 @@ So here is our next script, C: my $dh = DH->new({ schema => $schema, - script_directory => "$FindBin::Bin/dbicdh", + script_directory => "$FindBin::Bin/../dbicdh", databases => 'SQLite', sql_translator_args => { add_drop_table => 0 }, });