2017 © Pedro Peláez
 

library version

A simple database versioning system for ZF2 applications.

image

valorin/version

A simple database versioning system for ZF2 applications.

  • Monday, December 10, 2012
  • by valorin
  • Repository
  • 0 Watchers
  • 0 Stars
  • 14 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

ZF2 Version Module v2

I've stopped working on this module because I found Phinx, a fantastic DB Migration tool. I recommend you use it!, (*1)

I'm working on ZF2 Module to integrate it into a ZF2 application: zf2-phinx-module., (*2)

Legacy information

A simple versioning system for ZF2 applications using the Zend\Console package to provide a secure way to manage versions. It currently supports the Zend\Db\Adapter class for database management, although it has been built to handle other adapter modules if required. (Feel free to implement your own and make a Pull Request.), (*3)

IMPORTANT: This module is still very much in development., (*4)

Installation Instructions

  1. Install compser, and add "valorin/version": "dev-master" to your ./composer.json:, (*5)

    {
        "require": {
            "valorin/version": "dev-master"
        }
    }
    
  2. Run ./composer.phar install to download the module into your application., (*6)

  3. Add the module (ValVersion) config/application.config.php:, (*7)

    <?php
    return array(
        // ...
        'modules' => array(
            'Application',
            // ...
            'ValVersion',
        ),
        // ...
    );
    
  4. Add the configuration to config/autoload/global.php, updating paths as required:, (*8)

    <?php
    return array(
        // ...
        'valversion' => Array(
            'DbAdapter' => Array(
                'class_dir'       => __DIR__ ."/../../data/versions",
                'class_namespace' => "\Application\Version",
            ),
        ),
        // ...
    );
    
  5. Create version scripts in your specified class_dir, following the template:, (*9)

    Filename: [#version]-[ClassName].php
    i.e:     0-CreateStructure.php
    
    <?php
    namespace Application\Version;
    
    use ValVersion\Script\VersionAbstract;
    
    class CreateStructure extends VersionAbstract
    {
        public function upgrade($adapter)
        {
            $sql = Array(
                "CREATE TABLE `table1` (
                  // ...
                )",
    
                "CREATE TABLE `table2` (
                  // ...
                )",
            );
    
            foreach ($sql as $query) {
                $adapter->query($query, \Zend\Db\Adapter\Adapter::QUERY_MODE_EXECUTE);
            }
    
            return true;
        }
    
    
        public function downgrade($adapter)
        {
            $sql = Array(
                "DROP TABLE IF EXISTS `table1`",
                "DROP TABLE IF EXISTS `table2`",
            );
    
    
            foreach ($sql as $query) {
                $adapter->query($query, \Zend\Db\Adapter\Adapter::QUERY_MODE_EXECUTE);
            }
    
            return true;
        }
    }
    
  6. Version Management should now be available via the ZF Console interface., (*10)

    valorin@gandalf:~/workspace/zf$ php ./public/index.php
    > ValVersion module v2.0.0 alpha
    
    Version Management
      index.php version status              Display the current version status of application.
      index.php version upgrade             Upgrade the application to the latest version.
      index.php version upgrade   TARGET    Upgrade the application to the specified version.
      index.php version downgrade TARGET    Downgrade the application to the specified version.
    

Have fun :), (*11)

Licence

See LICENCE.txt., (*12)

The Versions

10/12 2012

dev-master

9999999-dev https://github.com/valorin/valversion

A simple database versioning system for ZF2 applications.

  Sources   Download

BSD-3-Clause

The Requires

 

zf2 db version

01/11 2012

2.0.0-alpha3

2.0.0.0-alpha3 https://github.com/valorin/valversion

A simple database versioning system for ZF2 applications.

  Sources   Download

BSD-3-Clause

The Requires

 

zf2 db version

30/10 2012

2.0.0-alpha2

2.0.0.0-alpha2 https://github.com/valorin/ValVersion

A simple database versioning system for ZF2 applications.

  Sources   Download

BSD-3-Clause

The Requires

 

zf2 db version

29/10 2012

2.0.0-alpha

2.0.0.0-alpha https://github.com/valorin/ValVersion

A simple database versioning system for ZF2 applications.

  Sources   Download

BSD-3-Clause

The Requires

 

zf2 db version