NAME

DBIx::Migration::Classes::Change - Base class for database changes

SYNOPSIS

To create a new migration, just create a new child class:

libpath/MyApp/Changes/MyChangeTwo.pm:

package MyApp::Changes::MyChangeTwo;
use base qw(DBIx::Migration::Classes::Change);

sub after { "MyApp::Changes::MyChangeOne" }
sub perform {
  my ($self) = @_;
  $self->add_column('tablename', 'new_column', 'varchar(42)', -null => 1, -primary_key => 1);
  $self->create_table('new_table');
  return 1;
}
1;

DESCRIPTION

This module is the base class all migration changes inherit from.

Methods to overwrite

These methods should be overwritten in order to define the specific change that the class represents.

after()

The after method returns the name of change class which is the direct predecessor of the current change class.

If an empty string is returned, it means, this change does not depend on any other change. There is usually only one change class in an application with no predecessor, the first change. Though it is possible to have many root change classes, this is very unlikely and seldom what you want/need.

perform()

The perform method registers actual changes (e.g. "drop this table", "remove that column" etc.) to be part of the change class. How you can register changes in the change class, is described below.

Manipulating the database (registering changes for a change class)

These methods should NOT be overwritten and allow to register actual changes (manipulations) to be registered for this change class.

create_table( name )

alter_table_rename( old-tablename, new-tablename )

alter_table_add_column( tablename, columnname )

alter_table_drop_column( tablename, columnname )

alter_table_modify_column( tablename, columnname )

alter_table_rename_column( tablename, old-columnname, new-columnname )

drop_table( tablename )

EXPORT

None by default.

SEE ALSO

None.

AUTHOR

Tom Kirchner, <tom@tomkirchner.com>

COPYRIGHT AND LICENSE

Copyright (C) 2011 by Tom Kirchner

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.9 or, at your option, any later version of Perl 5 you may have available.