Tyler MacDonald > DBIx-Migration-Directories-0.11 > DBIx::Migration::Directories::Build

Download:
DBIx-Migration-Directories-0.11.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Source   Latest Release: DBIx-Migration-Directories-0.12

NAME ^

DBIx::Migration::Directories::Build - Build a package that includes a migration schema

SYNOPSIS ^

  our %opts = (
      module_name         =>  'Schema::RDBMS::MySchema',
      license             =>  'perl',
      requires            =>  {
          'DBIx::Migration::Directories'  =>  '0.01',
          'DBIx::Transaction'             =>  '0.005',
      },
      build_requires      =>  {
        'Module::Build'                 =>  '0.27_03',
        'Test::Exception'               =>  '0.21',
      },
      create_makefile_pl  =>  'passthrough',
  );

  eval { require DBIx::Migration::Directories::Build; };

  my $build;

  if($@) {
      warn "DBIx::Migration::Directories::Build is required to build this module!";
      # they don't have the build class, so the install won't work anyways.
      # set installdirs to an empty hash to ensure that the "install" action
      # can't run successfully.
      $build = Module::Build->new(%opts, installdirs => {});
  } else {
      $build = DBIx::Migration::Directories::Build->new(%opts);
  }
  
  $build->create_build_script;

DESCRIPTION ^

When DBIx::Migration::Directories is installed, the user is asked where they would like database migration schemas to live. (This usually defaults to something like "/usr/local/share/schemas".) Packages that use DBIx::Migration::Directories should then install their schemas into a sub-directory of this, named after their package or schema name. That way, the migration code can find and use these schemas easily.

DBIx::Migration::Directories::Build is a subclass of Module::Build, which ensures that your database schemas are installed in this manner.

USAGE ^

If your package only supplies one schema, you can simply create a schema directory structure (as described by "DIRECTORY STRUCTURE" in DBIx::Migration::Directories) in a "schema" directory in the base of your package. When "Build install" is run, this schema will be installed into the appropriate place.

If your package supplies multiple schemas, you can create a "schemas" directory instead, and create sub-directories for each schema below that. (Eg; schemas/My-Schema-Foo, schemas/My-Schema-Bar, etc.)

SCHEMA NAMING ^

When using the "schema" directory, by default, your schema will be named after your package, with double-colons (::) replaced by dashes, (-), as is the perl way. For example, if the package "My::Package" had a "schema" directory, that would be installed as /path/to/schemas/My-Package.

If you want your schema to be named something else when it is installed, you can override the default behaviour by passing the "schema_name" argument to the DBIx::Migration::Directories::Build constructor. This could be useful if it's a particular module inside your package that defines/versions the schema (see "desired_version_from" in DBIx::Migration::Directories).

AUTHOR ^

Tyler "Crackerjack" MacDonald <japh@crackerjack.net>

LICENSE ^

Copyright 2006 Tyler "Crackerjack" MacDonald <japh@crackerjack.net>

This is free software; You may distribute it under the same terms as perl itself.

SEE ALSO ^

DBIx::Migration::Directories, Module::Build

syntax highlighting: