PHPackages                             purocean/php-db-migration - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. purocean/php-db-migration

ActiveLibrary[Database &amp; ORM](/categories/database)

purocean/php-db-migration
=========================

A database migration tool

v0.0.1(9y ago)5212MITPHPPHP &gt;=5.6.0

Since Jan 20Pushed 9y ago2 watchersCompare

[ Source](https://github.com/purocean/php-db-migration)[ Packagist](https://packagist.org/packages/purocean/php-db-migration)[ Docs](https://github.com/purocean/php-db-migration)[ RSS](/packages/purocean-php-db-migration/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

数据库迁移工具，仿照Yii2
==============

[](#数据库迁移工具仿照yii2)

```
仅支持 MySQL

```

使用
--

[](#使用)

```
// migration.php
date_default_timezone_set('PRC');
$migrationConfig = [
    'tablePrefix' => 'test_prefix_', // 表前缀
    'migrationsPath' => __DIR__.'/migrations', // 迁移储存位置
    'dbConfig' => [ // 数据库配置
        'username' => 'root',
        'password' => '',
        'dsn' => 'mysql:host=localhost;port=3306;dbname=db_migration_test;charset=utf8',
    ]
];

(new \DbMigration\Cli($migrationConfig))->run();
```

```
php migration.php help
```

迁移示例：/test/migrations/m170119\_101310\_test\_migration.php

功能
--

[](#功能)

- create 创建迁移
- up 升级一个迁移
- down 降级一个迁移
- mark 讲某个迁移标记为已升级/未升级
- new 显示未升级迁移
- history 查看迁移历史

测试
--

[](#测试)

```
cd test
vim config.php # 修改数据库配置
php test.php
```

MySQL
-----

[](#mysql)

- execute
- createTable
- renameTable
- dropTable
- truncateTable
- addColumn
- dropColumn
- renameColumn
- alterColumn
- addPrimaryKey
- dropPrimaryKey
- addForeignKey
- dropForeignKey
- createIndex
- dropIndex
- addCommentOnColumn()
- addCommentOnTable
- dropCommentFromColumn
- dropCommentFromTable
- primaryKey
- char
- varchar
- string
- text
- smallInteger
- integer
- bigInteger
- float
- double
- decimal
- dateTime
- timestamp
- time
- date
- binary
- boolean
- notNull
- null
- unique
- defaultValue
- comment
- unsigned
- after
- first
- append

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3396d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/788b15496d4992227987785a659ea132c0d4b32b701a767c3820059e70bab73a?d=identicon)[purocean](/maintainers/purocean)

---

Top Contributors

[![purocean](https://avatars.githubusercontent.com/u/7115690?v=4)](https://github.com/purocean "purocean (24 commits)")

---

Tags

migrationdatabasemysqldb

### Embed Badge

![Health badge](/badges/purocean-php-db-migration/health.svg)

```
[![Health](https://phpackages.com/badges/purocean-php-db-migration/health.svg)](https://phpackages.com/packages/purocean-php-db-migration)
```

###  Alternatives

[fpdo/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

921244.9k7](/packages/fpdo-fluentpdo)[odan/phinx-migrations-generator

Migration generator for Phinx

235847.8k23](/packages/odan-phinx-migrations-generator)[cybercog/laravel-clickhouse

ClickHouse migrations for Laravel

163166.8k](/packages/cybercog-laravel-clickhouse)[rah/danpu

Zero-dependency MySQL dump library for easily exporting and importing databases

64401.8k10](/packages/rah-danpu)[awssat/laravel-sync-migration

Laravel tool helps to sync migrations without refreshing the database

10923.2k](/packages/awssat-laravel-sync-migration)[dbout/wp-orm

WordPress ORM with Eloquent.

1279.6k1](/packages/dbout-wp-orm)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
