2017 © Pedro Peláez
 

yii2-extension yii2-schemadump

Generate the schema from an existing database

image

jamband/yii2-schemadump

Generate the schema from an existing database

  • Tuesday, May 15, 2018
  • by jamband
  • Repository
  • 11 Watchers
  • 72 Stars
  • 15,454 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 17 Forks
  • 5 Open issues
  • 12 Versions
  • 5 % Grown

The README.md

yii2-schemadump

Build Status Latest Stable Version Total Downloads, (*1)

Generate the schema from an existing database., (*2)

Demo

gif, (*3)

Requirements

  • PHP 7.4 or later
  • Yii 2.x

Installation

composer require --dev jamband/yii2-schemadump

Usage

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

return [
    ...
    'components' => [
        ...
    ],
    'controllerMap' => [
        'migrate' => [
            'class' => yii\console\controllers\MigrateController::class,
            'templateFile' => '@jamband/schemadump/template.php',
        ],
        'schemadump' => [
            'class' => jamband\schemadump\SchemaDumpController::class,
            'db' => [
                'class' => yii\db\Connection::class,
                'dsn' => 'mysql:host=localhost;dbname=existing_database_name',
                'username' => 'your_username',
                'password' => 'your_password',
            ],
        ],
    ],
    ...
];

And run schemadump command., (*5)

cd /path/to/project
./yii schemadump

Example output:, (*6)

// user
$this->createTable('{{%user}}', [
    'id' => $this->primaryKey()->comment('主キー'),
    'username' => $this->string(20)->notNull()->unique()->comment('ユーザ名'),
    'email' => $this->string(255)->notNull()->unique()->comemnt('メールアドレス'),
    'password' => $this->string(255)->notNull()->comment('パスワード'),
], $this->tableOptions);

Copy the output code and paste it into a migration file., (*7)

Commands

Generates the 'createTable' code. (default), (*8)

./yii schemadump
./yii schemadump/create

Generates the 'dropTable' code., (*9)

./yii schemadump/drop

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

./yii schemadump | pbcopy
./yii schemadump/drop | pbcopy

Check help., (*11)

./yii help schemadump

Supports

  • Types
  • Size
  • Unsigned
  • NOT NULL
  • DEFAULT value
  • COMMENT
  • Unique key
  • Foreign key
  • Composite primary keys
  • Primary key without AUTO_INCREMENT
  • ENUM type (for MySQL)

The Versions

15/05 2018

dev-master

9999999-dev https://github.com/jamband/yii2-schemadump

Generate the schema from an existing database

  Sources   Download

MIT

The Requires

 

The Development Requires

database extension command yii2 generator migration

28/01 2017

v0.10.0

0.10.0.0 https://github.com/jamband/yii2-schemadump

Generate the schema from an existing database

  Sources   Download

MIT

The Requires

 

The Development Requires

database extension command yii2 generator migration

17/12 2015

v0.9.9

0.9.9.0 https://github.com/jamband/yii2-schemadump

Generate the schema from an existing database

  Sources   Download

MIT

The Requires

 

database extension command yii2 generator migration

10/12 2015

v0.9.8

0.9.8.0 https://github.com/jamband/yii2-schemadump

Generate the schema from an existing database

  Sources   Download

MIT

The Requires

 

database extension command yii2 generator migration

02/05 2015

v0.9.7

0.9.7.0 https://github.com/jamband/yii2-schemadump

Generate the schema from an existing database

  Sources   Download

MIT

The Requires

 

command yii2 generator migration extesion

09/04 2015

v0.9.6

0.9.6.0 https://github.com/jamband/yii2-schemadump

Generate the schema from an existing database

  Sources   Download

MIT

The Requires

 

command yii2 generator migration extesion

08/12 2014

v0.9.5

0.9.5.0 https://github.com/jamband/yii2-schemadump

Generate the schema from an existing database

  Sources   Download

MIT

The Requires

 

command yii2 generator migration extesion

08/12 2014

v0.9.4

0.9.4.0 https://github.com/jamband/yii2-schemadump

Generate the schema from an existing database

  Sources   Download

MIT

The Requires

 

command yii2 generator migration extesion

03/12 2014

v0.9.3

0.9.3.0 https://github.com/jamband/yii2-schemadump

Generate the schema from an existing database

  Sources   Download

MIT

The Requires

 

command yii2 generator migration extesion

27/11 2014

v0.9.2

0.9.2.0 https://github.com/jamband/yii2-schemadump

Generate the schema from an existing database

  Sources   Download

MIT

command yii2 generator migration extesion

26/11 2014

v0.9.1

0.9.1.0 https://github.com/jamband/yii2-schemadump

Generate the schema from an existing database

  Sources   Download

MIT

command yii2 generator migration extesion

25/11 2014

v0.9.0

0.9.0.0 https://github.com/jamband/yii2-schemadump

Generate the schema from an existing database

  Sources   Download

MIT

command yii2 generator migration extesion