allenjb/migrationmanager 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Latest Version on Packagist Software License

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.

统计信息

  • 总下载量: 24
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固