allenjb/migrationmanager
Composer 安装命令:
composer require allenjb/migrationmanager
包简介
A simple, framework agnostic, MySQL non-reversible migrations library that accepts a pre-configured PDO connection
README 文档
README
A simple, framework agnostic, MySQL non-reversible migrations library that accepts a pre-configured PDO connection (allowing you to preset desired connection configuration such as sql_mode or timezone and your own error handling).
Why? I looked at other libraries for migrations but they all had a large number of issues around MySQL language support and reversals, or controlling the mysql connection (eg. timezone, sql_mode) is problematic because they control creation of the connection. While I could try to enforce not using the problematic features, it's much easier if they aren't available in the first place.
Versions
Use version 1 for compatibility with PHP 5.6. Version 2+ require PHP 7.1+
Install
Via Composer
$ composer require allenjb/migrationmanager
Usage
$pdo = new \PDO(...); $pathToMigrations = "../db/migrations/"; $migrationsTable = 'migrations'; $manager = new AllenJB\MigrationManager($pdo, $pathToMigrations, $migrationsTable); // List migrations print_r ($manager->executedMigrations()); print_r ($manager->migrationsToExecute()); print_r ($manager->futureMigrations()); // Perform pending migrations $manager->executeMigrations(); // You MUST call when you've finished using the manager to release all locks $manager->unlock();
Migration Files
Filenames MUST be in the format YYYYMMDD_HHmm_ClassName.php
Time is in 24 hour format.
ClassName must be unique.
If the date is greater than today (disregarding time), then the migration will not be executed until that date. This allows you to schedule migrations in the future (for example, you're removing a field but want to leave it in the database for a period to guard against dataloss / code rollbacks).
<?php declare(strict_types = 1); // example filename: 20170330_1100_Initialize.php use AllenJB\MigrationManager\AbstractMigration; class Initialize extends AbstractMigration { public function up() : void { // Execute your changes here, using $this->db to access the PDO connection } }
License
The MIT License (MIT). Please see License File for more information.
allenjb/migrationmanager 适用场景与选型建议
allenjb/migrationmanager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24 次下载、GitHub Stars 达 1, 最近一次更新时间为 2017 年 03 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「migration」 「pdo」 「AllenJB」 「MigrationManager」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 allenjb/migrationmanager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 allenjb/migrationmanager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 allenjb/migrationmanager 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Lets you add foreign keys in a swift! Foreign key adder in laravel migration.
Manage PostgreSQL schemas in Laravel applications
Bitrix db migration core libs
The YADM migrations
Data migration mechanism for php using dbal do doctrine with pdo, schema and queryBuilder
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-03-30