定制 cycle/migrations 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

cycle/migrations

最新稳定版本:v4.2.6

Composer 安装命令:

composer require cycle/migrations

包简介

Database migrations, migration scaffolding

README 文档

README

Latest Stable Version Build Status Scrutinizer Code Quality Codecov

Migrations are a convenient way for you to alter your database in a structured and organized manner. This package adds additional functionality for versioning your database schema and easily deploying changes to it. It is a very easy to use and a powerful tool.

Installation

composer require cycle/migrations ^4.0

Configuration

use Cycle\Migrations;
use Cycle\Database;
use Cycle\Database\Config;

$dbal = new Database\DatabaseManager(new Config\DatabaseConfig([
    'default' => 'default',
    'databases' => [
        'default' => [
            'connection' => 'sqlite'
        ]
    ],
    'connections' => [
        'sqlite' => new Config\SQLiteDriverConfig(
            connection: new Config\SQLite\MemoryConnectionConfig(),
            queryCache: true,
        ),
    ]
]));

$config = new Migrations\Config\MigrationConfig([
    'directory' => __DIR__ . '/../migrations/',    // where to store migrations
    'vendorDirectories' => [                       // Where to look for vendor package migrations
        __DIR__ . '/../vendor/vendorName/packageName/migrations/'
    ],
    'table' => 'migrations'                       // database table to store migration status
    'safe' => true                                // When set to true no confirmation will be requested on migration run. 
]);

$migrator = new Migrations\Migrator(
    $config, 
    $dbal, 
    new Migrations\FileRepository($config)
);

// Init migration table
$migrator->configure();

Running

while (($migration = $migrator->run()) !== null) {
    echo 'Migrate ' . $migration->getState()->getName();
}

Generate Migrations

You can automatically generate a set of migration files during schema compilation. In this case, you have the freedom to alter such migrations manually before running them. To achieve that you must install the Schema migrations generator extension.

License:

MIT License (MIT). Please see LICENSE for more information. Maintained by Spiral Scout.

统计信息

  • 总下载量: 498.36k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 20
  • 点击次数: 1
  • 依赖项目数: 33
  • 推荐数: 5

GitHub 信息

  • Stars: 20
  • Watchers: 3
  • Forks: 18
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-29