The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Moodle

ABSTRACT

Migrations for Mojo DB Drivers

SYNOPSIS

  use Moodle;
  use Mojo::Pg;
  use App::Migrator;

  my $migrator = App::Migrator->new;
  my $driver = Mojo::Pg->new('postgresql://postgres@/test');

  my $self = Moodle->new(migrator => $migrator, driver => $driver);

  my $migration = $self->migrate('latest');

DESCRIPTION

Moodle uses Doodle with Mojo database drivers to easily install and evolve database schema migrations. See Doodle::Migrator for help setting up Doodle migrations, and Mojo::Pg, Mojo::mysql or Mojo::SQLite for help configuring the DB driver.

METHODS

This package implements the following methods.

content

  content() : Str

The content method generates DB migration statements using the Doodle::Migrator and return a string containing "UP" and "DOWN" versioned migration strings suitable for use with the migration feature of Mojo database drivers.

content example
  my $content = $self->content;

migrate

  migrate(Maybe[Str] $target) : Object

The migrate method generates DB migration statements using the Doodle::Migrator and installs them using one of the Mojo database drivers, i.e. Mojo::Pg, Mojo::mysql or Mojo::SQLite. The method returns a migration object relative to to the DB driver used.

migrate example
  my $migrate = $self->migrate;

  my $latest = $self->migrate('latest');