This migration will help you with updating database whith new versions of source code
It's recommended that you use Composer to install InterventionSDK.
composer require bixev/migrations "~1.0"
This will install this library and all required dependencies.
so each of your php scripts need to require composer autoload file
<?php
require 'vendor/autoload.php';
Use a given or custom migration store. It will store your migrations versions.
$migrationsStore = new \Bixev\Migrations\VersionStore\MysqlVersionStore();
$migrationsStore->setDb(new PDO(''), 'table_name');
Instanciate migrations API
$migrationsApi = new \Bixev\Migrations\API($migrationsStore);
You have to give the api as many updaters as you have migrations file extensions
$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
$migrationsApi->update('namespace', 'update/directory');
You can use logger to log update informations.
$logger = new \Bixev\LightLogger\StdLogger();
$migrationsStore = new \Bixev\Migrations\VersionStore\MysqlVersionStore($logger);
$migrationsApi = new \Bixev\Migrations\API($migrationsStore, $logger);