src/Resources/DbSchemaResource.php
protected function createTableFields($table_name, $fields)
    {
        if (!is_array($fields) || empty($fields)) {
            throw new \Exception('There are no fields in the requested schema.');
        }

        if (!isset($fields[0])) {
            // single record possibly passed in without wrapper array
            $fields = [$fields];
        }

        $schema = $this->parent->getSchema();

        $internalTableName = $table_name;
        if ((false === strpos($table_name, '.')) && !empty($namingSchema = $this->parent->getNamingSchema())) {
            $internalTableName = $namingSchema . '.' . $table_name;
        }
        $columns = [];
        $references = [];
        $indexes = [];
        $extras = [];
        $commands = [];
        foreach ($fields as $field) {
            $this->cleanClientField($field);
            $name = array_get($field, 'name');

            // clean out extras
            $extraNew = array_only($field, $this->fieldExtras);
            $field = array_except($field, $this->fieldExtras);

            $type = strtolower((string)array_get($field, 'type'));
            if (!$schema->supportsResourceType(DbResourceTypes::TYPE_TABLE_FIELD) ||
                array_get($extraNew, 'is_virtual', false)
            ) {
                // no need to build what the db doesn't support, use extras and bail
                $extraNew['extra_type'] = $type;
            } else {
                if ($schema->isUndiscoverableType($type)) {
                    $extraNew['extra_type'] = $type;
                }

                $result = $this->buildTableField($internalTableName, $field);
                $commands = array_merge($commands, (array)array_get($result, 'commands'));
                $references = array_merge($references, (array)array_get($result, 'references'));
                $indexes = array_merge($indexes, (array)array_get($result, 'indexes'));

                $columns[$name] = $field;
            }

            if (!empty($extraNew)) {
                $extraNew['table'] = $table_name;
                $extraNew['field'] = $name;
                $extras[] = $extraNew;
            }
        }

        return [
            'columns'    => $columns,
            'references' => $references,
            'indexes'    => $indexes,
            'extras'     => $extras,
            'commands'   => $commands,
        ];
    }
protected function createTableFields($table_name, $fields)
    {
        if (!is_array($fields) || empty($fields)) {
            throw new \Exception('There are no fields in the requested schema.');
        }

        if (!isset($fields[0])) {
            // single record possibly passed in without wrapper array
            $fields = [$fields];
        }

        $schema = $this->parent->getSchema();

        $internalTableName = $table_name;
        if ((false === strpos($table_name, '.')) && !empty($namingSchema = $this->parent->getNamingSchema())) {
            $internalTableName = $namingSchema . '.' . $table_name;
        }
        $columns = [];
        $references = [];
        $indexes = [];
        $extras = [];
        $commands = [];
        foreach ($fields as $field) {
            $this->cleanClientField($field);
            $name = array_get($field, 'name');

            // clean out extras
            $extraNew = array_only($field, $this->fieldExtras);
            $field = array_except($field, $this->fieldExtras);

            $type = strtolower((string)array_get($field, 'type'));
            if (!$schema->supportsResourceType(DbResourceTypes::TYPE_TABLE_FIELD) ||
                array_get($extraNew, 'is_virtual', false)
            ) {
                // no need to build what the db doesn't support, use extras and bail
                $extraNew['extra_type'] = $type;
            } else {
                if ($schema->isUndiscoverableType($type)) {
                    $extraNew['extra_type'] = $type;
                }

                $result = $this->buildTableField($internalTableName, $field);
                $commands = array_merge($commands, (array)array_get($result, 'commands'));
                $references = array_merge($references, (array)array_get($result, 'references'));
                $indexes = array_merge($indexes, (array)array_get($result, 'indexes'));

                $columns[$name] = $field;
            }

            if (!empty($extraNew)) {
                $extraNew['table'] = $table_name;
                $extraNew['field'] = $name;
                $extras[] = $extraNew;
            }
        }

        return [
            'columns'    => $columns,
            'references' => $references,
            'indexes'    => $indexes,
            'extras'     => $extras,
            'commands'   => $commands,
        ];
    }
@param string $table_name
@param array  $fields

@throws \Exception
@return array