roolith/migration 问题修复 & 功能扩展

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

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

roolith/migration

最新稳定版本:1.2.0

Composer 安装命令:

composer require roolith/migration

包简介

php simple migration

README 文档

README

Simple migration and seeding tool for PHP applications.

Installation

You can install roolith-migration using Composer:

composer require roolith/migration

Usage

Create a PHP file migration.php and add the following code:

use Roolith\Migration\Migration;

require __DIR__ . "/../vendor/autoload.php";

$migration = new Migration();
$migration
    ->settings([
        "folder" => __DIR__ . "/migrations",
        "database" => [
            "host" => "localhost",
            "name" => "db_name",
            "user" => "user",
            "pass" => "pass",
        ],
    ])
    ->run($argv);

Command

Assuming your filename is migration.php, you can run the migration command as follows:

php migration.php migration:create migration_name
php migration.php migration:run # it will run all pending migrations
php migration.php migration:run migration_name
php migration.php migration:rollback migration_name
php migration.php migration:status

For seeding data, you can use the following command:

php migration.php seeder:create seed_name
php migration.php seeder:run # it will run all pending seeds
php migration.php seeder:run seed_name

Notes

  • it will create migrations table if not exists
  • it will create migrations folder if not exists
  • You can change the name of the folder by passing settings

Example of migration file

php migration.php migration:create create_users_table
<?php

use Roolith\Store\Interfaces\DatabaseInterface;
use Roolith\Migration\Interfaces\MigrationInterface;

class CreateUsersTable implements MigrationInterface
{
    public function up(DatabaseInterface $db): void {}

    public function down(DatabaseInterface $db): void {}
}

Example of seed file

php migration.php seed:create add_users
<?php

use Roolith\Migration\Interfaces\SeederInterface;
use Roolith\Store\Interfaces\DatabaseInterface;

class AddUsers implements SeederInterface
{
    public function run(DatabaseInterface $db): void {}
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-18