2017 © Pedro Peláez
 

yii2-extension yii2-migration

Yii2 helper to simplify of writing migration

image

execut/yii2-migration

Yii2 helper to simplify of writing migration

  • Saturday, September 30, 2017
  • by eXeCUT
  • Repository
  • 1 Watchers
  • 2 Stars
  • 110 Installations
  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 4 % Grown

The README.md

yii2-migration

This is a typical migration for yii2:, (*1)

    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:, (*2)

    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

The preferred way to install this extension is through composer., (*3)

Install

Either run, (*4)

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

or add, (*5)

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

to the require section of your composer.json file., (*6)

Usage

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

     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., (*8)

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

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

Supported databases

Currently only supported PostgreSQL and MySQL. Also you can use BDR plugin for PostgreSQL., (*10)

The Versions

30/09 2017

dev-master

9999999-dev https://github.com/execut/yii2-migration

Yii2 helper to simplify of writing migration

  Sources   Download

Apache-2.0

The Requires

 

by Avatar eXeCUT

yii2

30/09 2017

1.4.2

1.4.2.0 https://github.com/execut/yii2-migration

Yii2 helper to simplify of writing migration

  Sources   Download

Apache-2.0

The Requires

 

by Avatar eXeCUT

yii2

30/08 2017

1.4.1

1.4.1.0 https://github.com/execut/yii2-migration

Yii2 helper to simplify of writing migration

  Sources   Download

Apache-2.0

The Requires

 

by Avatar eXeCUT

yii2

15/05 2017

1.3.2

1.3.2.0 https://github.com/execut/yii2-migration

Yii2 helper to simplify of writing migration

  Sources   Download

Apache-2.0

The Requires

 

by Avatar eXeCUT

yii2

15/05 2017

1.4.0

1.4.0.0 https://github.com/execut/yii2-migration

Yii2 helper to simplify of writing migration

  Sources   Download

Apache-2.0

The Requires

 

by Avatar eXeCUT

yii2

01/05 2017

1.3.1

1.3.1.0 https://github.com/execut/yii2-migration

Yii2 helper to simplify of writing migration

  Sources   Download

Apache-2.0

The Requires

 

by Avatar eXeCUT

yii2

09/04 2017

1.3.0

1.3.0.0 https://github.com/execut/yii2-migration

Yii2 helper to simplify of writing migration

  Sources   Download

Apache-2.0

The Requires

 

by Avatar eXeCUT

yii2

02/04 2017

1.2.1

1.2.1.0 https://github.com/execut/yii2-migration

Yii2 helper to simplify of writing migration

  Sources   Download

Apache-2.0

The Requires

 

by Avatar eXeCUT

yii2

02/04 2017

1.2.0

1.2.0.0 https://github.com/execut/yii2-migration

Yii2 helper to simplify of writing migration

  Sources   Download

Apache-2.0

The Requires

 

by Avatar eXeCUT

yii2

02/04 2017

1.1.0

1.1.0.0 https://github.com/execut/yii2-migration

Yii2 helper to simplify of writing migration

  Sources   Download

Apache-2.0

The Requires

 

by Avatar eXeCUT

yii2

28/03 2017

1.0.0

1.0.0.0 https://github.com/execut/yii2-migration

Yii2 helper to simplify of writing migration

  Sources   Download

Apache-2.0

The Requires

 

by Avatar eXeCUT

yii2