PHPackages                             antonyz89/yii2-migrate - 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. antonyz89/yii2-migrate

ActiveYii2-extension[Database &amp; ORM](/categories/database)

antonyz89/yii2-migrate
======================

1.0(5y ago)11.7kBSD-3-ClausePHP

Since Sep 18Pushed 3y ago1 watchersCompare

[ Source](https://github.com/AntonyZ89/yii2-migrate)[ Packagist](https://packagist.org/packages/antonyz89/yii2-migrate)[ RSS](/packages/antonyz89-yii2-migrate/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (6)Used By (0)

yii2-migrate
============

[](#yii2-migrate)

[ ![Donate with PayPal](https://camo.githubusercontent.com/648ad6f048733f167bf65e11a4fd759eef14da88db61ad078bbd5ddea5d57133/68747470733a2f2f7777772e70617970616c6f626a656374732e636f6d2f656e5f55532f692f62746e2f62746e5f646f6e6174655f4c472e676966)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YATHVT293SXDL&source=url)Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist antonyz89/yii2-migrate dev-master

```

or add

```
"antonyz89/yii2-migrate": "dev-master"

```

to the require section of your `composer.json` file.

USAGE
-----

[](#usage)

**console/config/main.php**

```
'controllerMap' => [
    'migrate' => [
        'class' => 'antonyz89\migrate\MigrateController'
    ],
],

```

MIGRATE COMMANDS
----------------

[](#migrate-commands)

`yii migrate/create`

`yii migrate/fresh`

`yii migrate/full` ( Fresh + Seeder ) ( requires [antonyz89/yii2-seeder](https://github.com/AntonyZ89/yii2-seeder) )

MIGRATION
---------

[](#migration)

It is no longer necessary to create index and foreign keys, columns that end with `_id` will have a foreign key associated with the name that comes before `_id`.

Example:

`company_id` column is a foreign key to the `company` table.

If this is not the case, add your column to the variable `$ignoreColumns` and these columns will not have indexing or foreign key automatically associated with them.

```
public $ignoreColumns = [
    'company_id'
];
```

To disable association of indexing and foreign keys for all columns, simply assign `$autoGenerateIndexAndForeignKey = false`

```
public $autoGenerateIndexAndForeignKey = true;
```

When a column is added individually (`addColumn()`), an index and a foreign key are also generated if the column follows the pattern mentioned above. The procedures for disabling automatic association are the same

When a column is dropped (`dropColumn()`), if a foreign key exists, it is automatically removed. If for some reason you don't want this to happen, just `public $autoDropForeignKey = false;` or add the column in `$ignoreColumns` to disable it for specific columns.

to create a index and foreign key use `indexAndForeignKey($column, $options = [])`

`$options` example:

```
$options = [
    'table' => '{{%user}}',
    'ref_table' => 'company',
    'ref_table_id' => 'id',
    'delete' => 'CASCADE',
    'update' => 'CASCADE'
];

// in migrate
$this->indexAndForeignKey('company_id', $options);
```

To set global default value of `ON UPDATE` and `ON DELETE`, replace `Migration::$onDelete` and ` Migration::$onUpdate` in `bootstrap.php`

```
use antonyz89\migrate\Migration;

Migration::$onDelete = 'RESTRICT'; // default: CASCADE
Migration::$onUpdate = 'CASCADE'; // default: CASCADE
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Every ~118 days

Total

5

Last Release

1588d ago

Major Versions

0.1 → 1.02020-09-18

### Community

Maintainers

![](https://www.gravatar.com/avatar/68c187c364cc778fd93b1ca011536893e6fc1e9e9c1b0dfee490fb23904265ae?d=identicon)[AntonyDev](/maintainers/AntonyDev)

---

Top Contributors

[![AntonyZ89](https://avatars.githubusercontent.com/u/1340674?v=4)](https://github.com/AntonyZ89 "AntonyZ89 (23 commits)")

---

Tags

yii2extensionwidgetmigrateantonyz89yii2-migrate

### Embed Badge

![Health badge](/badges/antonyz89-yii2-migrate/health.svg)

```
[![Health](https://phpackages.com/badges/antonyz89-yii2-migrate/health.svg)](https://phpackages.com/packages/antonyz89-yii2-migrate)
```

###  Alternatives

[sjaakp/yii2-sortable-behavior

Sort ActiveRecords and related records in Yii2.

36144.7k](/packages/sjaakp-yii2-sortable-behavior)[johnitvn/yii2-ajaxcrud

Gii CRUD template for Single Page Ajax Administration for yii2

97209.6k16](/packages/johnitvn-yii2-ajaxcrud)[dmstr/yii2-migrate-command

Console Migration Command with multiple paths/aliases support

31295.5k6](/packages/dmstr-yii2-migrate-command)[dmstr/yii2-db

Database extensions

19618.8k6](/packages/dmstr-yii2-db)

PHPackages © 2026

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