2017 © Pedro Peláez
 

yii2-extension yii2-db-migrate

This extension allows you to easily create large migrations associated with many foreign keys.

image

lav45/yii2-db-migrate

This extension allows you to easily create large migrations associated with many foreign keys.

  • Saturday, May 5, 2018
  • by LAV45
  • Repository
  • 2 Watchers
  • 0 Stars
  • 3,418 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 7 Versions
  • 1 % Grown

The README.md

yii2-db-migrate

Это расширение поможет вам избежать конфликтов в вашей SQL db при создании foreign key., (*1)

Установка расширения

~$ composer require --prefer-dist lav45/yii2-db-migrate

Подключение

use lav45\db\MainMigration;

class m000000_000000_init extends MainMigration
{
    // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
    public $defaultTableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';

    public function table_news()
    {
        $this->createTable('news', [
            'id' => $this->primaryKey(),
            'author_id' => $this->integer()->notNull(),
            // ...
        ]);

        $this->addForeignKey('news', 'author_id', 'user', 'id', 'SET NULL');
    }

    public function table_news_tag()
    {
        $this->createTable('news_tag', [
            'news_id' => $this->integer()->notNull(),
            'tag_id' => $this->integer()->notNull(),
        ]);

        $this->addPrimaryKey('news_tag', ['news_id', 'tag_id']);

        $this->addForeignKey('news_tag', 'news_id', 'news', 'id');
        $this->addForeignKey('news_tag', 'tag_id', 'tag', 'id');
    }

    public function table_tag()
    {
        $this->createTable('tag', [
            'id' => $this->primaryKey(),
            // ...
        ]);
    }

    public function table_user()
    {
        $this->createTable('user', [
            'id' => $this->primaryKey(),
            // ...
        ]);
    }
}
~$ php yii migrate/up
Yii Migration Tool (based on Yii v2.0.7-dev)

Creating migration history table "migration"...Done.
Total 1 new migrations to be applied:
        m000000_000000_init

*** applying m000000_000000_init
    > create table user ... done (time: 0.072s)
    > create table news ... done (time: 0.064s)
    > add foreign key news_author_id_fkey: news (author_id) references user (id) ... done (time: 0.001s)
    > create table news_tag ... done (time: 0.001s)
    > add primary key news_tag_pk on news_tag (news_id,tag_id) ... done (time: 0.086s)
    > add foreign key news_tag_news_id_fkey: news_tag (news_id) references news (id) ... done (time: 0.001s)
    > create table tag ... done (time: 0.066s)
    > add foreign key news_tag_tag_id_fkey: news_tag (tag_id) references tag (id) ... done (time: 0.001s)
*** applied m000000_000000_init (time: 0.292s)


1 migrations were applied.

Migrated up successfully.

The Versions

05/05 2018

dev-master

9999999-dev https://github.com/lav45/yii2-db-migrate

This extension allows you to easily create large migrations associated with many foreign keys.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Loban

extension yii2 db migrate

03/02 2017

0.4.1

0.4.1.0 https://github.com/lav45/yii2-db-migrate

This extension allows you to easily create large migrations associated with many foreign keys.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Loban

extension yii2 db migrate

02/12 2015

0.4.0

0.4.0.0 https://github.com/lav45/yii2-db-migrate

This extension allows you to easily create large migrations associated with many foreign keys.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Loban

extension yii2 db migrate

04/07 2015

0.3.1

0.3.1.0 https://github.com/lav45/yii2-db-migrate

This extension allows you to easily create large migrations associated with many foreign keys.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Loban

extension yii2 db migrate

23/06 2015

0.3.0

0.3.0.0 https://github.com/lav45/yii2-db-migrate

This extension allows you to easily create large migrations associated with many foreign keys.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Loban

extension yii2 db migrate

04/06 2015

0.2.0

0.2.0.0 https://github.com/lav45/yii2-db-migrate

This extension allows you to easily create large migrations associated with many foreign keys.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Loban

extension yii2 db migrate

01/06 2015

0.1.0

0.1.0.0 https://github.com/lav45/yii2-db-migrate

This extension allows you to easily create large migrations associated with many foreign keys.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Loban

extension yii2 db migrate