PHPackages                             ank/migrations - 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. ank/migrations

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

ank/migrations
==============

database migrations

2.0.2(5y ago)072MITPHP

Since Jan 13Pushed 5y ago1 watchersCompare

[ Source](https://github.com/zhaokeli/ank-migrations)[ Packagist](https://packagist.org/packages/ank/migrations)[ RSS](/packages/ank-migrations/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (3)Versions (29)Used By (0)

ank-migrations
==============

[](#ank-migrations)

项目配置
====

[](#项目配置)

在项目的公共配置文件中添加迁移配置，不要添加到业务访问模块

```
'migrations'  => [
    'name'       => 'Stat Db Migrations',
    'name_space' => 'migration',
    'table_name' => 'migration',
    'paths'      => [dirname(dirname(__DIR__)) . '/migration'],
],
```

- name 为项目的名字,可自定义
- name\_space 为迁移类的命名空间，尽量保持默认，跟框架的命名空间规则一至
- table\_name 迁移类在数据库生成的迁移记录表名字，不带前缀
- paths 数组,迁移类所在路径(绝对路径),一般路径跟 controller 目录同级(跟框架目录规则一至) 以上配置可以在多个项目中设置，迁移命令执行的时候会自动合并，但顺序不确定，所以建议除啦 **paths** 外其它配置项只配置一次

生成迁移脚本
======

[](#生成迁移脚本)

```
./vendor/bin/ank-db generate
```

执行迁移到最新版本
=========

[](#执行迁移到最新版本)

```
./vendor/bin/ank-db migrate
```

--dry-run是空转参数，只显示操作结果，不执行修改
============================

[](#--dry-run是空转参数只显示操作结果不执行修改)

```
./vendor/bin/ank-db migrate --dry-run
```

不执行操作，只写入文件，对于生产环境需要手动验证并执行的场景有用
================================

[](#不执行操作只写入文件对于生产环境需要手动验证并执行的场景有用)

```
./vendor/bin/ank-db migrate --write-sql=file.sql
```

查看详细信息
======

[](#查看详细信息)

```
./vendor/bin/ank-db status
```

迁移到指定版本
=======

[](#迁移到指定版本)

```
./vendor/bin/ank-db migrate 20180608161758
```

使用别名迁移到指定版本
===========

[](#使用别名迁移到指定版本)

- first:回退到初始版本
- prev:回到上一个版本
- next:迁移到下一个版本
- latest:迁移到最新版本（和不加版本号效果一样）

单独迁移指定版本的脚本
===========

[](#单独迁移指定版本的脚本)

```
./vendor/bin/ank-db execute 20180601193057 --down/--up

```

其它参数
====

[](#其它参数)

- --no-interaction 不用确定，直接执行
- --write-sql=migration.sql 使用此参数后，所有操作不在数据库中执行，而是将操作的sql写到指定文件中

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 97.6% 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

Every ~14 days

Recently: every ~29 days

Total

28

Last Release

1932d ago

Major Versions

1.0.24 → 2.0.02020-12-10

### Community

Maintainers

![](https://www.gravatar.com/avatar/e531cf3f13357c2fc120a3c9335f05a92a88ac517a584dd7f0595865c4c129c7?d=identicon)[735579768](/maintainers/735579768)

---

Top Contributors

[![735579768](https://avatars.githubusercontent.com/u/2497797?v=4)](https://github.com/735579768 "735579768 (40 commits)")[![zhaokeli](https://avatars.githubusercontent.com/u/2497841?v=4)](https://github.com/zhaokeli "zhaokeli (1 commits)")

### Embed Badge

![Health badge](/badges/ank-migrations/health.svg)

```
[![Health](https://phpackages.com/badges/ank-migrations/health.svg)](https://phpackages.com/packages/ank-migrations)
```

###  Alternatives

[damienharper/auditor-bundle

Integrate auditor library in your Symfony projects.

4542.8M](/packages/damienharper-auditor-bundle)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[overtrue/laravel-versionable

Make Laravel model versionable.

585308.0k5](/packages/overtrue-laravel-versionable)[worksome/foggy

Foggy is a tool for making database dumps with some data removed/changed.

26571.7k1](/packages/worksome-foggy)[mnapoli/dbal-schema

DB schema manager for Doctrine DBAL

9732.9k1](/packages/mnapoli-dbal-schema)[flow-php/doctrine-dbal-bulk

Bulk inserts and updates for Doctrine DBAL

14295.2k1](/packages/flow-php-doctrine-dbal-bulk)

PHPackages © 2026

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