Dave Rolsky > Database-Migrator-0.09 > Database::Migrator::Core

Download:
Database-Migrator-0.09.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.09   Source   Latest Release: Database-Migrator-0.11

NAME ^

Database::Migrator::Core - Core role for Database::Migrator implementation classes

VERSION ^

version 0.09

SYNOPSIS ^

  package Database::Migrator::SomeDB;

  use Moose;
  with 'Database::Migrator::Core';

  sub _build_database_exists { ... }
  sub _build_dbh             { ... }
  sub _create_database       { ... }

DESCRIPTION ^

This role implements the bulk of the migration logic, leaving a few details up to DBMS-specific classes.

You can then subclass these DBMS-specific classes to provide defaults for various attributes, or to override some of the implementation.

PUBLIC ATTRIBUTES ^

This role defines the following public attributes. These attributes may be provided via the command line or you can set defaults for them in a subclass.

METHODS ^

This role provide just one public method, create_or_update_database().

It will create a new database if none exists.

It will run all unapplied migrations on this schema once it does exist.

REQUIRED METHODS ^

If you want to create your own implementation class, you must implement the following methods. All of these methods should throw an error

$migration->_create_database()

This should create an empty database. This role will take care of executing the DDL for defining the schema.

$migration->_driver_name()

This return a string containing the DBI driver name, such as "mysql" or "Pg".

$migration->_drop_database()

This should drop the database. Right now it is only used for testing.

$migration->_run_ddl($ddl)

Given a string containing one or more DDL statements, this method must run that DDL against the database.

OVERRIDEABLE ATTRIBUTES AND METHODS ^

There are a number of attributes methods in this role that you may wish to override in a custom subclass of an implementation.

For any attribute where you provide a default value, make sure to also set required => 0 as well.

AUTHOR ^

Dave Rolsky <autarch@urth.org>

COPYRIGHT AND LICENSE ^

This software is Copyright (c) 2013 by MaxMind, Inc..

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)
syntax highlighting: