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;
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.
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.
###http://[Your_Domain]/utility/index###
Workbench showing the user table:
Image of demo page:
If you see this error.
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',
];
- Table prefix added
- Column defaultValue allows for array/expression
- Enum options escaping and uppercase
Please provide any helpful feedback or requests.
Thanks.