PHPackages                             execut/yii2-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. execut/yii2-migration

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

execut/yii2-migration
=====================

Yii2 helper to simplify of writing migration

1.8.2(5y ago)276118Apache-2.0PHP

Since Mar 28Pushed 5y ago1 watchersCompare

[ Source](https://github.com/execut/yii2-migration)[ Packagist](https://packagist.org/packages/execut/yii2-migration)[ Docs](https://github.com/execut/yii2-migration)[ RSS](/packages/execut-yii2-migration/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (20)Used By (8)

yii2-migration
==============

[](#yii2-migration)

This is a typical migration for yii2:

```
    public function safeUp()
    {
        $this->createTable('characteristics_units', [
            'id' => $this->primaryKey(),
            'name' => $this->string()->notNull(),
            'short_name' => $this->string()->notNull(),
            'created' => $this->dateTime()->notNull()->defaultExpression('now()'),
            'updated' => $this->dateTime(),
        ]);

        $this->createTable('characteristics', [
            'id' => $this->primaryKey(),
            'characteristics_unit_id' => $this->integer()->notNull(),
            'name' => $this->string()->notNull(),
            'created' => $this->dateTime()->notNull()->defaultExpression('now()'),
            'updated' => $this->dateTime(),
        ]);

        $this->addForeignKey('characteristics_unit_id_characteristics_fk', 'characteristics', 'characteristics_unit_id', 'characteristics_units', 'id');
    }

    public function safeDown()
    {
        $this->dropTable('characteristics');
        $this->dropTable('characteristics_units');
    }
```

Why write more? If you use execut yii2-migration helper, you can write it faster and more compact:

```
    public function initInverter(\execut\yii\migration\Inverter $i)
    {
        $i->table('characteristics')->create(array_merge($this->defaultColumns(), [
            'name' => $this->string()->notNull(),
            'short_name' => $this->string()->notNull(),
        ]));

        $i->table('characteristics_units')->create(array_merge($this->defaultColumns(), [
            'name' => $this->string()->notNull(),
        ]))->addForeignColumn('characteristics');
    }
```

Installation
------------

[](#installation)

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

### Install

[](#install)

Either run

```
$ php composer.phar require execut/yii2-migration "dev-master"

```

or add

```
"execut/yii2-migration": "dev-master"

```

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

Usage
-----

[](#usage)

To use yii2 migration, simply expand the migration class from the execut\\yii\\migration\\Migration class and override the abstract method:

```
     public function initInverter(\execut\yii\migration\Inverter $i)
     {
     }
```

$i has all the methods that normal migration has, but allows you to write actions up and down at a time.

To permanently do not rewrite the migration, you can define a new template for the yii migrate\\create command.

```
    'controllerMap' => [
        'migrate' => [
            'templateFile' => '@vendor/execut/yii2-migration/views/template.php',
        ],
```

Supported databases
-------------------

[](#supported-databases)

Currently only supported PostgreSQL and MySQL. Also you can use BDR plugin for PostgreSQL.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity72

Established project with proven stability

 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 ~67 days

Recently: every ~92 days

Total

19

Last Release

2173d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2357407?v=4)[Yuriy Mamaev](/maintainers/execut)[@execut](https://github.com/execut)

---

Top Contributors

[![execut](https://avatars.githubusercontent.com/u/2357407?v=4)](https://github.com/execut "execut (31 commits)")

---

Tags

yii2

### Embed Badge

![Health badge](/badges/execut-yii2-migration/health.svg)

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.0k](/packages/craftcms-cms)[bizley/migration

Migration generator for Yii 2.

296389.5k11](/packages/bizley-migration)[yii2tech/illuminate

Yii2 to Laravel Migration Package

11416.2k](/packages/yii2tech-illuminate)[mootensai/yii2-relation-trait

Yii 2 Models load with relation, &amp; transaction save with relation

49232.7k9](/packages/mootensai-yii2-relation-trait)[nhkey/yii2-activerecord-history

Storage history of changes to ActiveRecord

46148.8k1](/packages/nhkey-yii2-activerecord-history)[dmstr/yii2-db

Database extensions

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

PHPackages © 2026

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