From: Arthur Axel 'fREW' Schmidt Date: Sun, 4 Jul 2010 07:29:09 +0000 (-0500) Subject: MOAR TUTORIAL X-Git-Tag: v0.001002~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=af333e79b0a77a2dd4e72873c4e7a024b936e80d;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git MOAR TUTORIAL --- diff --git a/lib/DBIx/Class/DeploymentHandler/Manual/Intro.pod b/lib/DBIx/Class/DeploymentHandler/Manual/Intro.pod index c7e7a7d..1ca76f1 100644 --- a/lib/DBIx/Class/DeploymentHandler/Manual/Intro.pod +++ b/lib/DBIx/Class/DeploymentHandler/Manual/Intro.pod @@ -1,14 +1,21 @@ -=head1 NAME +package DBIx::Class::DeploymentHandler::Manual::Intro -DBIx::Class::DeploymentHandler::Intro - Introduction to DBIx::Class::DeploymentHandler +# ABSTRACT: Introduction to DBIx::Class::DeploymentHandler -=head1 Why DBIx::Class::DeploymentHandler is worth using +=pod +=head1 Why is DBIx::Class::DeploymentHandler worth using? -=head1 Our Sample database +The most obvious reasons for using DBIx::Class::DeploymentHandler are +that it can run multiple SQL scripts as well as Perl scripts, unlike +DBIx::Class::Schema::Versioned, which only allows for a single SQL script. +It is also extremely extensible, and is an opportunity for a break from +backwards compatibility, so some regrettable decisions are avoided. -Follow L except for the parts setting up the database. -After you are done, You should have the following files. +=head1 Sample database + +Follow L except for the parts setting up the +database. After you are done, You should have the following files. MyDatabase/ |-- Main @@ -19,6 +26,18 @@ After you are done, You should have the following files. | `-- ResultSet `-- Main.pm +Add a line like the following in your MyDatabase::Main file: + + our $VERSION = 1; + +or if you are using a newer Perl you can use the prettier syntax: + + package MyDatabase::Main 1; + +By default DBIx::Class::DeploymentHandler only uses integers for versions, +this makes versioning much simpler for figuring out what version is next +(or previous.) + =head1 install.pl Our first script, C reads our schema file and creates the tables @@ -38,11 +57,10 @@ in the database. script_directory => "$FindBin::Bin/dbicdh", databases => 'SQLite', sql_translator_args => { add_drop_table => 0 }, - schema_version => 1, }); $dh->prepare_install; - $dh->install({ version => 1 }); + $dh->install; =head2 dbicdh - Our migration scripts @@ -68,6 +86,22 @@ that is suitable for SQLite This contains all of the raw information about our schema that is then translated into the sql. +=head3 Population + +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'], + ]); + }; + =head1 Upgrading Add a line to MyDatabase/Main/Result/Cd.pm below @@ -128,3 +162,6 @@ The new C and C files are the state of the db as at that version. The C file is the most interesting one; it is what gets your database from version 1 to 2. +And again, you can create a Perl file like we did previously with the +deploy stage. +