Skip to content

Automatically writes the create tables for migrations or create tables in general. Uses MySQL

License

Notifications You must be signed in to change notification settings

diesonne/yii2-migration-utility

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yii2 Migration Utility

Updated July 27, 2014

This is a simple utility that writes the create table statement for you. The table(s) must already exist.

Supports

  • MySQL
  • MsSQL
  • PgSQL
  • SQLite

It automatically writes out all:

  • tables
  • columns
  • column types
  • column defaults
  • primary keys
  • foreign key
  • does not add indexes

Note: Foreign keys default to CASCADE / DELETE so you may need to manually change these.

Note: $tableOptions is added so make sure you have a var set.

Note: $dbType is used with the if/then statements.

$dbType = Yii::$app->db->driverName;

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist "c006/yii2-migration-utility" "dev-master"

or add

"c006/yii2-migration-utility": "dev-master"

to the require section of your composer.json file.

Required

Update either config/web.php (basic) or config/main.php (advanced)

    'modules'    => [
        ...
        ...
        ...
        'utility' => [
            'class' => 'c006\utility\migration\Module',
        ],
    ],

The tables must already exist in website schema.

Usage

###http://[Your_Domain]/utility/index###

Workbench showing the user table:

alt text

Image of demo page:

alt text

Errors

If you see this error.

Error Message

In this file vendor/c006/yii2-migration-utility/assets/AppAssets.php

comment out these lines.

    public $depends = [
        // 'yii\web\YiiAsset',
        // 'yii\widgets\ActiveFormAsset',
        // 'yii\bootstrap\BootstrapAsset',
    ];

Updates

  • Table prefix added
  • Column defaultValue allows for array/expression
  • Enum options escaping and uppercase

Contributors

Comments / Suggestions

Please provide any helpful feedback or requests.

Thanks.

About

Automatically writes the create tables for migrations or create tables in general. Uses MySQL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 96.4%
  • JavaScript 3.6%