Skip to content

Latest commit

 

History

History
52 lines (36 loc) · 1.48 KB

README.md

File metadata and controls

52 lines (36 loc) · 1.48 KB

ZfSimpleMigrations

Simple Migrations for Zend Framework 2. Project originally based on ZendDbMigrations but module author did not response for issues and pull-requests so fork became independent project.

Installation

Using composer

php composer.phar require vgarvardt/zf-simple-migrations:dev-master
php composer.phar update

add ZfSimpleMigrations to the modules array in application.config.php

Usage

Available commands

  • migration version - show last applied migration
  • migration list [--all] - list available migrations (all includes applied migrations)
  • migration apply [<version>] [--force] [--down] [--fake] - apply or rollback migration
  • migration generate - generate migration skeleton class

Migration classes are stored in /path/to/project/migrations/ dir by default.

Generic migration class has name Version<YmdHis> and implement ZfSimpleMigrations\Library\MigrationInterface.

Migration class example

<?php

namespace ZfSimpleMigrations\Migrations;

use ZfSimpleMigrations\Library\AbstractMigration;
use Zend\Db\Metadata\MetadataInterface;

class Version20130403165433 extends AbstractMigration
{
    public static $description = "Migration description";

    public function up(MetadataInterface $schema)
    {
        //$this->addSql(/*Sql instruction*/);
    }

    public function down(MetadataInterface $schema)
    {
        //$this->addSql(/*Sql instruction*/);
    }
}