2017 © Pedro PelĆ”ez
 

yii2-extension yii2-dump

Generate the schema from an existing database

image

hzhihua/yii2-dump

Generate the schema from an existing database

  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 36 % Grown

The README.md

yii2-dump

Generate migration file from an existing database, (*1)

github: https://github.com/Hzhihua/yii2-dump
oschina: http://git.oschina.net/hzhihua/yii2-dump, (*2)

Demo

yii2-dump, (*3)

Test Environment

  • PHP >= 5.5.0
  • MySQL(5.6.36)

Installation

composer require --prefer-dist "hzhihua/yii2-dump:1.0.3"

Configuration

Add the following in console/config/main.php:, (*4)

Simple Configuration

return [
    'controllerMap' => [
        'dump' => [
            'class' => 'hzhihua\dump\DumpController',
            'filePrefix' => '123456_654321',
            'tableOptions' => 'ENGINE=InnoDB CHARACTER SET=utf8 COLLATE=utf8_unicode_ci', // if mysql >= 5.7, you can set ā€œENGINE=InnoDB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_unicode_ciā€,
        ],
    ],
];

Detail Configuration Ā see

return [
    'controllerMap' => [
        'dump' => [
            'class' => 'hzhihua\\dump\\DumpController',
 Ā  Ā  Ā  Ā  Ā  Ā 'db' => 'db', // Connection
            'templateFile' => '@vendor/hzhihua/yii2-dump/templates/migration.php',
            'generatePath' => '@console/migrations',
            'table' => 'table1,table2', // select which table will be dump(default filter migration table)
            'filter' => 'table3,table4', // table3 and table4 will be filtered when generating migration file
            'limit' => '0,1000', // select * from tableName limit 0,1000
            'filePrefix' => '123456_654321',
            'tableOptions' => 'ENGINE=InnoDB CHARACTER SET=utf8 COLLATE=utf8_unicode_ci', // if mysql >= 5.7, you can set ā€œENGINE=InnoDB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_unicode_ciā€,
            // ... ...
        ],
    ],
];

Default Table Options

ENGINE=InnoDB CHARACTER SET=utf8 COLLATE=utf8_unicode_ci

it was defined at "@vendor/hzhihua/yii2-dump/src/Migration.php" file see, (*5)

Default Limit

0,1000

Default Filter Table

migration, (*6)

Tips

You may neet to remove the migration file that its name is "*_init.php" before you run "./yii migrate" commond. because it will generate "{{%user}}" table file when you run "./yii dump" commond and the file name with "*_init.php" also create "{{%user}}" table. it will tip you "{{%user}}" has always exits., (*7)

Simple Usage

run dump command., (*8)

cd /path/to/your-project
./yii dump # default action: generate, it will gerate migration file

Commands

Check help, (*9)

./yii help dump

print all over the table name without table prefix, (*10)

./yii dump/list

generate all over the table migration file(default filter migration table), (*11)

./yii dump
or
./yii dump/generate

generate all over the table migration file but it only had some data between 0 and 10, (*12)

./yii dump -limit=10

only generate table1,table2 migration file, (*13)

./yii dump -table=table1,table2

only generate table1,table2 migration file and only table1 will be dumped table data, (*14)

./yii dump -table=table1,table2 -data=table1

generate all over the migration table file without table1,table2, (*15)

./yii dump -filter=table1,table2

print all over the code of migration table file(default filter migration table), (*16)

./yii dump/create

Display the 'createTable' code at the terminal., (*17)

./yii dump/create

Display the 'dropTable' code at the terminal., (*18)

./yii dump/drop

-type params, (*19)

./yii dump -type=0/1/2/3
>>> -type=0 generate table migration file,
>>> -type=1 generate table data migration file,
>>> -type=2 generate add key migration file,
>>> -type=3 generate add foreign key migration file

Useful commands (for macOS user):, (*20)

./yii dump | pbcopy
./yii dump/drop | pbcopy

Supports

  • Types
  • Size
  • Unsigned
  • NOT NULL
  • DEFAULT Value
  • COMMENT
  • Unique key
  • Foreign key
  • Primary key
  • ENUM type (for MySQL)
  • AUTO_INCREMENT

Not Supports

~~AUTO_INCREMENT~~, (*21)

The Versions

02/05 2018

dev-master

9999999-dev https://github.com/Hzhihua/yii2-dump

Generate the schema from an existing database

  Sources   Download

BSD-3-Clause BSD-3

The Requires

  • php >=5.5.0

 

database extension command yii2 generator migration

02/05 2018

1.0.3

1.0.3.0 https://github.com/Hzhihua/yii2-dump

Generate the schema from an existing database

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.5.0

 

database extension command yii2 generator migration

01/02 2018

1.0.2

1.0.2.0 https://github.com/Hzhihua/yii2-dump

Generate the schema from an existing database

  Sources   Download

BSD-3-Clause

The Requires

 

database extension command yii2 generator migration

14/09 2017

1.0.1

1.0.1.0 https://github.com/Hzhihua/yii2-dump

Generate the schema from an existing database

  Sources   Download

BSD-3

The Requires

 

database extension command yii2 generator migration

10/09 2017

1.0.0

1.0.0.0 https://github.com/Hzhihua/yii2-dump

Generate the schema from an existing database

  Sources   Download

BSD-3

The Requires

 

database extension command yii2 generator migration