lib/gii/cascadeTypeModule/Generator.php
public function generateCreateTableColumns($table)
    {
        $fields = [];
        $queryBuilder = $this->getDbConnection()->getQueryBuilder();
    //	\d($table->columns );
        foreach ($table->columns as $column) {
            $nullExtra = $signedExtra = $defaultExtra = $primaryKeyExtra  = $autoIncrementExtra = '';
            $size = $column->size;
            if (!is_null($column->scale)) {
                $size .= ',' . $column->scale;
            }

            if (!$column->allowNull) {
                $nullExtra = ' NOT NULL';
            }

            if ($column->unsigned) {
                $signedExtra = ' unsigned';
            }
            if ($column->autoIncrement) {
                $autoIncrementExtra = ' AUTO_INCREMENT';
            }

            if ($column->isPrimaryKey and $this->getPrimaryKeyLocation($table) === 'table_build') {
                $primaryKeyExtra = ' PRIMARY KEY';
            }

            if (!empty($column->enumValues)) {
                $size = '\'' . implode('\',\'', $column->enumValues) . '\'';
            }

            $stringValue = $column->dbTypecast($column->defaultValue);
            if (is_null($stringValue)) {
                if ($column->allowNull) {
                    $stringValue = 'NULL';
                } else {
                    $stringValue = false;
                }
            } elseif (is_bool($stringValue)) {
                $stringValue = ($stringValue) ? 1 : 0;
            } else {
                $stringValue = $this->getDbConnection()->getSchema()->quoteValue($stringValue);
            }
            if ($stringValue !== false) {
                $defaultExtra = ' DEFAULT ' . addslashes($stringValue);
            }

            $field = "'{$column->name}' => '";

            // \canis\base\Debug::d($column);exit;
            $fieldType = $column->dbType;
            preg_match('/^(\w+)(\((.+?)\))?\s*(.+)$/', $fieldType, $fieldTypeParts);
            if (!isset($fieldTypeParts[1])) {
                var_dump($fieldTypeParts);
                var_dump($column);
                exit;
            }
            $fieldTypeBare = $fieldTypeParts[1];
            // if (isset($fieldTypeBare[4]) AND $fieldTypeBare[4] === 'unsigned') {
            // 	$signedExtra = ' unsigned';
            // }

            if ($fieldType === 'char(36)') {
                $fieldType = $column->dbType . ' CHARACTER SET ascii COLLATE ascii_bin';
            } elseif ($fieldType === 'tinyint(1)') {
                $fieldType = 'boolean';
            } elseif (substr($column->dbType, 0, 4) === 'enum') {
                $fieldType = $column->dbType;
            } elseif (isset($this->getDbConnection()->getSchema()->typeMap[$fieldTypeBare])) {
                $fieldType = $this->getDbConnection()->getSchema()->typeMap[$fieldTypeBare];
                $qb = $this->getDbConnection()->getQueryBuilder();
                if (isset($qb->typeMap[$fieldType])) {
                    preg_match('/^(\w+)(\((.+?)\))?\s*(.+)$/', $qb->typeMap[$fieldType], $baseTypeParts);
                    if (isset($fieldTypeParts[4]) && isset($baseTypeParts[4]) && $fieldTypeParts[4] !== $baseTypeParts[4]) {
                        $size = preg_replace('/[^0-9\,]/', '', $fieldTypeParts[4]);
                    }
                }
                if ($size !== false) {
                    $fieldType .= '(' . $size . ')';
                }
            }

            $fieldComplete = trim(addslashes($fieldType) . $signedExtra . $nullExtra . $defaultExtra . $autoIncrementExtra . $primaryKeyExtra);
            $field .= $fieldComplete . '\'';

            $fields[] = $field;
        }

        return implode(",\n\t\t\t", $fields);
    }
public function generateCreateTableColumns($table)
    {
        $fields = [];
        $queryBuilder = $this->getDbConnection()->getQueryBuilder();
    //	\d($table->columns );
        foreach ($table->columns as $column) {
            $nullExtra = $signedExtra = $defaultExtra = $primaryKeyExtra  = $autoIncrementExtra = '';
            $size = $column->size;
            if (!is_null($column->scale)) {
                $size .= ',' . $column->scale;
            }

            if (!$column->allowNull) {
                $nullExtra = ' NOT NULL';
            }

            if ($column->unsigned) {
                $signedExtra = ' unsigned';
            }
            if ($column->autoIncrement) {
                $autoIncrementExtra = ' AUTO_INCREMENT';
            }

            if ($column->isPrimaryKey and $this->getPrimaryKeyLocation($table) === 'table_build') {
                $primaryKeyExtra = ' PRIMARY KEY';
            }

            if (!empty($column->enumValues)) {
                $size = '\'' . implode('\',\'', $column->enumValues) . '\'';
            }

            $stringValue = $column->dbTypecast($column->defaultValue);
            if (is_null($stringValue)) {
                if ($column->allowNull) {
                    $stringValue = 'NULL';
                } else {
                    $stringValue = false;
                }
            } elseif (is_bool($stringValue)) {
                $stringValue = ($stringValue) ? 1 : 0;
            } else {
                $stringValue = $this->getDbConnection()->getSchema()->quoteValue($stringValue);
            }
            if ($stringValue !== false) {
                $defaultExtra = ' DEFAULT ' . addslashes($stringValue);
            }

            $field = "'{$column->name}' => '";

            // \canis\base\Debug::d($column);exit;
            $fieldType = $column->dbType;
            preg_match('/^(\w+)(\((.+?)\))?\s*(.+)$/', $fieldType, $fieldTypeParts);
            if (!isset($fieldTypeParts[1])) {
                var_dump($fieldTypeParts);
                var_dump($column);
                exit;
            }
            $fieldTypeBare = $fieldTypeParts[1];
            // if (isset($fieldTypeBare[4]) AND $fieldTypeBare[4] === 'unsigned') {
            // 	$signedExtra = ' unsigned';
            // }

            if ($fieldType === 'char(36)') {
                $fieldType = $column->dbType . ' CHARACTER SET ascii COLLATE ascii_bin';
            } elseif ($fieldType === 'tinyint(1)') {
                $fieldType = 'boolean';
            } elseif (substr($column->dbType, 0, 4) === 'enum') {
                $fieldType = $column->dbType;
            } elseif (isset($this->getDbConnection()->getSchema()->typeMap[$fieldTypeBare])) {
                $fieldType = $this->getDbConnection()->getSchema()->typeMap[$fieldTypeBare];
                $qb = $this->getDbConnection()->getQueryBuilder();
                if (isset($qb->typeMap[$fieldType])) {
                    preg_match('/^(\w+)(\((.+?)\))?\s*(.+)$/', $qb->typeMap[$fieldType], $baseTypeParts);
                    if (isset($fieldTypeParts[4]) && isset($baseTypeParts[4]) && $fieldTypeParts[4] !== $baseTypeParts[4]) {
                        $size = preg_replace('/[^0-9\,]/', '', $fieldTypeParts[4]);
                    }
                }
                if ($size !== false) {
                    $fieldType .= '(' . $size . ')';
                }
            }

            $fieldComplete = trim(addslashes($fieldType) . $signedExtra . $nullExtra . $defaultExtra . $autoIncrementExtra . $primaryKeyExtra);
            $field .= $fieldComplete . '\'';

            $fields[] = $field;
        }

        return implode(",\n\t\t\t", $fields);
    }
Generates Create table schema.

@param \yii\db\TableSchema $table the table schema

@return array the generated validation rules