bixev/migrations
最新稳定版本:1.2.1
Composer 安装命令:
composer require bixev/migrations
包简介
Bixev database migrations library
README 文档
README
This migration will help you with updating database whith new versions of source code
Installation
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';
Usage
Basic usage
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');
Log
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);
统计信息
- 总下载量: 15.59k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-03-29