DBIx::Migration::Classes::Change - Base class for database changes
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;
This module is the base class all migration changes inherit from.
These methods should be overwritten in order to define the specific change that the class represents.
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.
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.
These methods should NOT be overwritten and allow to register actual changes (manipulations) to be registered for this change class.
None by default.
None.
Tom Kirchner, <tom@tomkirchner.com>
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.
To install DBIx::Migration::Classes, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Migration::Classes
CPAN shell
perl -MCPAN -e shell install DBIx::Migration::Classes
For more information on module installation, please visit the detailed CPAN module installation guide.