2017 © Pedro Peláez
 

library migrations

Bixev database migrations library

image

bixev/migrations

Bixev database migrations library

  • Tuesday, March 29, 2016
  • by thomas.leviandier@gmail.com
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2,715 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 12 % Grown

The README.md

This migration will help you with updating database whith new versions of source code, (*1)

Installation

It's recommended that you use Composer to install InterventionSDK., (*2)

composer require bixev/migrations "~1.0"

This will install this library and all required dependencies., (*3)

so each of your php scripts need to require composer autoload file, (*4)

<?php

require 'vendor/autoload.php';

Usage

Basic usage

Use a given or custom migration store. It will store your migrations versions., (*5)

$migrationsStore = new \Bixev\Migrations\VersionStore\MysqlVersionStore();
$migrationsStore->setDb(new PDO(''), 'table_name');

Instanciate migrations API, (*6)

$migrationsApi = new  \Bixev\Migrations\API($migrationsStore);

You have to give the api as many updaters as you have migrations file extensions, (*7)

$migrationsApi->setUpdater('php', new \Bixev\Migrations\Updater\PhpUpdater());
$mysqlUpdater = new \Bixev\Migrations\Updater\MysqlUpdater();
$mysqlUpdater->setQueryExecutor(
    function ($query) use ($pdoMysql) {
        $replacements = ['${DEFAULT_ENGINE}' => 'pouet'];
        $query        = str_replace(array_keys($replacements), array_values($replacements), $query);
        $pdoMysql->query($query);
    }
);
$migrationsApi->setUpdater('sql', $mysqlUpdater);

Then, simply update with namespace and updates directory, (*8)

$migrationsApi->update('namespace', 'update/directory');

Log

You can use logger to log update informations., (*9)

$logger = new \Bixev\LightLogger\StdLogger();
$migrationsStore = new \Bixev\Migrations\VersionStore\MysqlVersionStore($logger);
$migrationsApi = new  \Bixev\Migrations\API($migrationsStore, $logger);

The Versions

29/03 2016

dev-master

9999999-dev

Bixev database migrations library

  Sources   Download

MIT

The Requires

 

29/03 2016

1.0.1

1.0.1.0

Bixev database migrations library

  Sources   Download

MIT

The Requires

 

29/03 2016

1.0.0

1.0.0.0

Bixev database migrations library

  Sources   Download

MIT

The Requires