DBIx::VersionedSchema - helps to manage database schema versions
package MyVersions; use base 'DBIx::VersionedSchema'; # Set the name of the table __PACKAGE__->Name('my_schema_versions'); # Add first version __PACKAGE__->add_version(sub { my $dbh = shift; $dbh->do(...); }); # Add another one __PACKAGE__->add_version(...); package main; my $vs = MyVersions->new($dbh); # recreates / adds versions $vs->run_updates;
This module helps to evolve database schema in small increments called schema versions henceforth.
Each of those versions is perl function that you pass to add_version function. Those versions are replayed by calling run_updates function.
DBIx::VersionedSchema keeps track of applied versions by using database table. You should provide the name of this table by using Name property of your inheriting class.
The tracking table will be created on the first call to run_updates function.
This is per class method. It should be used to set the name of the tracking table.
Adds another schema version as perl function. This function will run during run_updates call. Database handle will be provided to the function as an argument.
Creates new instance. $dbh is the database handle which will be passed down to the schema changing functions.
Returns current schema version. Returns undef if no version tracking table has been found. Returns 0 if the table exists but no updates have been run yet.
undef
Runs the updates starting from the current schema version.
Boris Sukholitko boriss@gmail.com
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
Test::TempDatabase - for creation of temporary databases.
To install DBIx::VersionedSchema, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::VersionedSchema
CPAN shell
perl -MCPAN -e shell install DBIx::VersionedSchema
For more information on module installation, please visit the detailed CPAN module installation guide.