Moodle
Mojo DB Driver Migrations
# migration: step #1 package Migration::Step1; use parent 'Doodle::Migration'; no warnings 'redefine'; sub up { my ($self, $doodle) = @_; my $table = $doodle->table('users'); $table->primary('id'); $table->create; return $doodle; } sub down { my ($self, $doodle) = @_; my $table = $doodle->table('users'); $table->delete; return $doodle; } # migration: step #2 package Migration::Step2; use parent 'Doodle::Migration'; no warnings 'redefine'; sub up { my ($self, $doodle) = @_; my $table = $doodle->table('users'); $table->string('email')->create; return $doodle; } sub down { my ($self, $doodle) = @_; my $table = $doodle->table('users'); $table->string('email')->delete; return $doodle; } # migration: root package Migration; use parent 'Doodle::Migration'; sub migrations {[ 'Migration::Step1', 'Migration::Step2', ]} # main program package main; use Moodle; my $self = Moodle->new( driver => $main::driver, migrator => Migration->new ); # $self->migrate;
This package uses Doodle with Mojo database drivers to easily install and evolve database schema migrations. See Doodle::Migration for help setting up Doodle migrations, and Mojo::Pg, Mojo::mysql or Mojo::SQLite for help configuring DB drivers.
This package uses type constraints from:
Moodle::Library
This package has the following attributes:
driver(Driver)
This attribute is read-only, accepts (Driver) values, and is required.
(Driver)
migrator(Migrator)
This attribute is read-only, accepts (Migrator) values, and is required.
(Migrator)
This package implements the following methods:
content() : Str
This method generates DB migration statements returning a string containing "UP" and "DOWN" versioned migration strings suitable for use with the migration feature of Mojo database drivers.
# given: synopsis my $content = $self->content;
migrate(Maybe[Str] $target) : Object
This method uses the DB migration statements generated by the "content" method and installs them using the Mojo database driver. This method returns a migration object relative to the DB driver used.
# given: synopsis my $migrate = $self->migrate;
Al Newkirk, awncorp@cpan.org
awncorp@cpan.org
Copyright (C) 2011-2019, Al Newkirk, et al.
This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".
Wiki
Project
Initiatives
Milestones
Contributing
Issues
To install Moodle, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Moodle
CPAN shell
perl -MCPAN -e shell install Moodle
For more information on module installation, please visit the detailed CPAN module installation guide.