petrknap/php-migrationtool
Composer 安装命令:
composer require petrknap/php-migrationtool
包简介
Migration tool for PHP
README 文档
README
What is Migration?
Data migration is the process of transferring data between storage types, formats, or computer systems. It is a key consideration for any system implementation, upgrade, or consolidation. Data migration is usually performed programmatically to achieve an automated migration, freeing up human resources from tedious tasks. Data migration occurs for a variety of reasons, including server or storage equipment replacements, maintenance or upgrades, application migration, website consolidation and data center relocation.
Usage of php-migrationtool
Migration files
Migration file is file placed in special directory like /migrations. Migration file name contains 3 parts: migration id, description separated by space (optional) and extension separated by dot (optional) - the valid names for migration files are {id}, {id}.{extension}, {id} {description} and {id} {description}.{extension}.
user@localhost:~/project/migrations$ ls
M0001 M0002.ext M0003 - Third migration M0004 - Fourth migration.ext
Migration tools process all files located in directory in ascending order (sorted by file names). If applying of any migration file throws exception, the changes invoked by this file will be canceled and migration tool will be stopped.
Migration tools also contain lists of applied migrations and guarantee that every file will be processed only once and only in case that there is not applied migration with higher id.
Migration tools
All migration tools implement MigrationToolInterface with method migrate().
<?php /** * @var $tool PetrKnap\Php\MigrationTool\MigrationToolInterface */ $tool->migrate();
SQL migration tool
WARNING: The SQL migration tool processes only files with extension sql.
<?php /** @var \Doctrine\DBAL\Connection $connection */ $tool = new PetrKnap\Php\MigrationTool\SqlMigrationTool( __DIR__ . '/migrations', $connection ); /** @var \Psr\Log\LoggerInterface $logger */ $tool->setLogger($logger); $tool->migrate();
SQL migration tool supports native SQL files as migration file. You can simply copy and paste output from orm:schema-tool:update --dump-sql, phpMyAdmin, Adminer or whatever with SQL output.
How to install
Run composer require petrknap/php-migrationtool or merge this JSON code with your project composer.json file manually and run composer install. Instead of dev-master you can use one of released versions.
{
"require": {
"petrknap/php-migrationtool": "dev-master"
}
}
Or manually clone this repository via git clone https://github.com/petrknap/php-migrationtool.git or download this repository as ZIP and extract files into your project.
petrknap/php-migrationtool 适用场景与选型建议
petrknap/php-migrationtool 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.18k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 06 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 petrknap/php-migrationtool 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 petrknap/php-migrationtool 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.18k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-06-23