PHPackages                             fornit1917/yii2-emigrate - 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. fornit1917/yii2-emigrate

ActiveYii2-extension

fornit1917/yii2-emigrate
========================

Yii2 Framework extension for simplification of code generation when creating some migrations

v0.1.1-alpha(11y ago)043MITPHPPHP &gt;=5.4.0

Since Jan 6Pushed 11y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (2)Used By (0)

yii2-emigrate
=============

[](#yii2-emigrate)

Yii2 Framework extension for simplification of code generation when creating some migrations. Code for up- and down-method in migration class may be generated based on the name of migration or additional command line parameters.

### Install

[](#install)

Install via composer:

`composer require "fornit1917/yii2-emigrate:dev-master"`

Then add ExtendedMigrateController in your controllerMap for console applications (file config/console.php):

```
    'controllerMap' => [
        'emigrate' => 'fornit1917\yii2emigrate\ExtendedMigrateController'
    ],

```

Now you can create migration with new yii2-emigrate:

`./yii emigrate/create create_table_table_name`

### Usage

[](#usage)

For automatic code generation migration it is necessary to give a special name:

- *create\_table\_table\_name* - for creation table with name "table\_name"
- *drop\_table\_table\_name* - for dropping table with name "table\_name"
- *add\_column\_column\_name\_in\_table\_name* - for adding new column with name "column\_name" in table "table\_name"
- *drop\_column\_column\_name\_in\_table\_name* - for dropping column with name "column\_name" in table "table\_name"

#### Create migrations for create table or drop table

[](#create-migrations-for-create-table-or-drop-table)

`./yii emigrate/create drop_table_table_name`

This command generate the next code:

```
