DBIx::VersionedSchema - helps to manage database schema versions


DBIx-VersionedSchema documentation  | view source Contained in the DBIx-VersionedSchema distribution.

Index


NAME

Top

DBIx::VersionedSchema - helps to manage database schema versions

SYNOPSIS

Top

	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;

DESCRIPTION

Top

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.

METHODS

Top

Name

This is per class method. It should be used to set the name of the tracking table.

add_version(function)

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.

new(dbh)

Creates new instance. $dbh is the database handle which will be passed down to the schema changing functions.

current_version

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.

run_updates

Runs the updates starting from the current schema version.

AUTHOR

Top

	Boris Sukholitko
	boriss@gmail.com

COPYRIGHT

Top

SEE ALSO

Top

Test::TempDatabase - for creation of temporary databases.


DBIx-VersionedSchema documentation  | view source Contained in the DBIx-VersionedSchema distribution.