2017 © Pedro Peláez
 

yii2-extension yii2-table-builder

Table builder migration helper extension for Yii 2

image

nkovacs/yii2-table-builder

Table builder migration helper extension for Yii 2

  • Wednesday, September 21, 2016
  • by nkovacs
  • Repository
  • 2 Watchers
  • 0 Stars
  • 12,974 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 7 % Grown

The README.md

Yii 2 migration table builder

Table builder migration helper extension for Yii 2, (*1)

Installation

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

Either run, (*3)

php composer.phar require --prefer-dist nkovacs/yii2-table-builder "*"

or add, (*4)

"nkovacs/yii2-table-builder": "*"

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

Usage

In order to use this extension, your migrations must extend from \nkovacs\tablebuilder\Migration. Once the extension is installed, it will override the migrate command's templateFile property during application bootstrap process, allowing you to use the extension's Migration class in newly created migrations, provided you did not override templateFile yourself., (*6)

An example migration:, (*7)

<?php

use yii\db\Schema;

class m140701_113939_test extends \nkovacs\tablebuilder\Migration
{
    public $tables;

    public function init()
    {
        parent::init();
        $this->tables = [
            '{{%table_a}}' => [
                'id'   => Schema::TYPE_PK,
                'name' => Schema::TYPE_STRING,
            ],
            '{{%table_b}}' => [
                'id'   => Schema::TYPE_PK,
                'name' => Schema::TYPE_STRING,
            ],
            '{{%table_c}}' => [
                'id'      => Schema::TYPE_PK,
                'user_id' => [Schema::TYPE_INTEGER, '{{%user}}', 'id', 'delete' => 'SET NULL', 'update' => 'CASCADE'],
                'a_id'    => [Schema::TYPE_INTEGER, '{{%table_a}}', 'id', 'delete' => 'RESTRICT', 'update' => 'CASCADE'],
                'b_id'    => [Schema::TYPE_INTEGER, '{{%table_b}}', 'id', 'delete' => 'RESTRICT', 'update' => 'CASCADE'],
                'name'    => Schema::TYPE_STRING,
            ],
            '{{%table_d}}' => [
                'a_id'    => [Schema::TYPE_INTEGER, '{{%table_a}}', 'id', 'delete' => 'RESTRICT', 'update' => 'CASCADE'],
                'b_id'    => [Schema::TYPE_INTEGER, '{{%table_b}}', 'id', 'delete' => 'RESTRICT', 'update' => 'CASCADE'],
                ['primary' => ['a_id', 'b_id']],
            ]
        ];
    }

    public function up()
    {
        $this->build($this->tables);
    }

    public function down()
    {
        $this->teardown($this->tables);
    }
}

The Versions

21/09 2016

dev-master

9999999-dev

Table builder migration helper extension for Yii 2

  Sources   Download

BSD-3-Clause

The Requires

 

by Nikola Kovacs

extension yii2 migration

21/09 2016

1.0.3

1.0.3.0

Table builder migration helper extension for Yii 2

  Sources   Download

BSD-3-Clause

The Requires

 

by Nikola Kovacs

extension yii2 migration

13/03 2015

1.0.2

1.0.2.0

Table builder migration helper extension for Yii 2

  Sources   Download

BSD-3-Clause

The Requires

 

by Nikola Kovacs

extension yii2 migration

05/11 2014

1.0.1

1.0.1.0

Table builder migration helper extension for Yii 2

  Sources   Download

BSD-3-Clause

The Requires

 

by Nikola Kovacs

extension yii2 migration

17/09 2014

1.0.0

1.0.0.0

Table builder migration helper extension for Yii 2

  Sources   Download

BSD-3-Clause

The Requires

 

by Nikola Kovacs

extension yii2 migration