DB::SQL::Migrations::Advanced - apply/rollback migrations from a directory
use DB::SQL::Migrations::Advanced; my $migrator = DB::SQL::Migrations::Advanced->new( dbh => $some_db_handle, folder => $some_path, ); $migrator->run; use DB::SQL::Migrations::Advanced; my $migrator = DB::SQL::Migrations::Advanced->new( dbh => $some_db_handle, folder => $some_path, rollback => 1, steps => 3, ); $migrator->run;
DB::SQL::Migrations::Advanced provides a nice way to apply migrations from a directory. It has the ability to also rollback migrations.
Tell list of already applied migrations.
Tell value for the last batch of migrations.
A database handler. (required)
Tell name of the folder that holds the migration files. Defaults to 'db_migrations'.
Migration files in alphabetical order.
Migrations that needs to be applied.
Tell if you are looking to rollback some migrations. Defaults to 0.
In case you are looking to rollback mirations, you can specify how many steps. Defaults to 1.
The name of the table that records the applied migrations. Defaults to 'schema_migrations'.
Apply all pending migrations.
Create migrations table if not exists.
Run migrations. Will decide if it needs to apply/rollback based on given attributes.
Record migration filename as being applied.
my $migration_key = $migrator->_migration_key($filename)
Retrieve the migration_key for a filename.
Revert migrations from filename.
Remove migration filename from table.
Run an sql.
my $sql = $migrator->_sql($filename)
Retrieve the sql that needs to be run from a migration filename, based on apply/rollback.
Adrian Crisan, <email@example.com>