Create a default index name for the table.

@param  string  $type
@param  array   $columns
@return string
320372
protected function createIndexName($type, array $columns)
    {
        $index = strtolower($this->table.'_'.implode('_', $columns).'_'.$type);

        return str_replace(array('-', '.'), '_', $index);
    }
1114566
protected function mapResponseToColumns($columns, $type)
    {
        $transformer = new DataArrayTransformer;

        return array_map(function ($row) use ($columns, $type, $transformer) {
            return $transformer->transform($row, $columns, $type);
        }, $this->getAjaxResponseData());
    }
774491
protected function createIndexName($type, array $columns)
    {
        $short_type = [
            'primary' => 'pk',
            'foreign' => 'fk',
            'unique'  => 'uk',
        ];

        $type = isset($short_type[$type]) ? $short_type[$type] : $type;

        $index = strtolower($this->prefix . $this->table . '_' . implode('_', $columns) . '_' . $type);

        $index = str_replace(['-', '.'], '_', $index);

        //shorten the name if it is longer than 30 chars
        while (strlen($index) > 30) {
            $parts = explode('_', $index);

            for ($i = 0; $i < count($parts); $i++) {
                //if any part is longer than 2 chars, take one off
                $len = strlen($parts[$i]);
                if ($len > 2) {
                    $parts[$i] = substr($parts[$i], 0, $len - 1);
                }
            }

            $index = implode('_', $parts);
        }

        return $index;
    }
548483
public function dropIndex(array $columns): AbstractTable
    {
        if (empty($schema = $this->current->findIndex($columns))) {
            throw new SchemaException(
                "Undefined index ['" . join("', '", $columns) . "'] in '{$this->getName()}'"
            );
        }

        //Dropping index from current schema
        $this->current->forgetIndex($schema);

        return $this;
    }
1067616
protected function getIndexesAnnotation($type = 'Index')
    {
        $indices = array();
        foreach ($this->getTableIndices() as $index) {
            switch (true) {
                case $type === 'Index' && $index->isIndex():
                case $type === 'UniqueConstraint' && $index->isUnique():
                    $columns = array();
                    foreach ($index->getColumns() as $column) {
                        $columns[] = $this->quoteIdentifier($column->getColumnName());
                    }
                    $indices[] = $this->getAnnotation($type, array('name' => $index->getName(), 'columns' => $columns));
                    break;

                default:
                    break;
            }
        }

        return count($indices) ? $indices : null;
    }
944110
protected function prepareColumn(Column $column)
    {
        $typeMapper = $this->getDataType();

        $type = $typeMapper::getType($column->getType());
        $length = $column->getLength() ?: $typeMapper::getLength($type);

        $length = $length ? '(' . $length . ')' : null;

        $column->type($type);

        // Prepare default value
        $this->prepareDefaultValue($column);

        return $column->length($length);
    }
451957
function setColumns($columns) {
		$this->columns = array();

		if ($columns === null) {
			return $this;
		}

		if (is_string($columns)) {
			return $this->addColumn($columns);
		}

		foreach ($columns as $alias => &$column) {
			$this->addColumn($column, is_int($alias) ? null : $alias);
		}
		return $this;
	}
512899
protected function forgetIndexType($type, $givenKeys)
    {
        $this->setKeywordsOperation(true);

        $givenKeys = is_array($givenKeys) ? $givenKeys : func_get_args();

        switch ($type) {
            case 'inverse':
                $getKeyCallback = function ($givenKey) {
                    return $this->generateInverseIndexKey($givenKey);
                };
                break;
            case 'keyword':
            default:
                $getKeyCallback = function ($givenKey) {
                    return $this->generateIndexKey($givenKey);
                };
                break;
        }

        $affected = [];
        foreach ($givenKeys as $givenKey) {
            $affected = array_merge($affected, parent::pull(call_user_func($getKeyCallback, $givenKey), []));
        }

        $this->setKeywordsOperation(false);

        return array_unique($affected);
    }
36470
public function addUniqueIndex( $type,$columns ) {
		$table = $this->safeTable($type,true);
		$name = 'UQ_'.$table.implode('__',$columns);
		$t = $this->getTable($type);
		if (isset($t['indexes'][$name])) return;
		$t['indexes'][$name] = array('name'=>$name);
		$this->putTable($t);
	}
972864
protected function addIndex($name, $type, $column)
    {
        if (isset($this->indexes[$name])) {
            $this->indexes[$name]['columns'][] = $column;
        }
        else {
            $this->indexes[$name] = [
                'name' => $name,
                'type' => $type,
                'columns' => [
                    $column
                ]
            ];
        }
    }
216708
public function getColumnDefaultValueDDL(Column $col)
    {
        $default = '';
        $defaultValue = $col->getDefaultValue();
        if (null !== $defaultValue) {
            $default .= 'DEFAULT ';
            if ($defaultValue->isExpression()) {
                $default .= $defaultValue->getValue();
            } else {
                if ($col->isTextType()) {
                    $default .= $this->quote($defaultValue->getValue());
                } elseif (in_array($col->getType(), [PropelTypes::BOOLEAN, PropelTypes::BOOLEAN_EMU])) {
                    $default .= $this->getBooleanString($defaultValue->getValue());
                } elseif ($col->getType() == PropelTypes::ENUM) {
                    $default .= array_search($defaultValue->getValue(), $col->getValueSet());
                } elseif ($col->isSetType()) {
                    $val = trim($defaultValue->getValue());
                    $values = [];
                    foreach (explode(',', $val) as $v) {
                        $values[] = trim($v);
                    }
                    $default .= SetColumnConverter::convertToInt($values, $col->getValueSet());
                } elseif ($col->isPhpArrayType()) {
                    $value = $this->getPhpArrayString($defaultValue->getValue());
                    if (null === $value) {
                        $default = '';
                    } else {
                        $default .= $value;
                    }
                } else {
                    $default .= $defaultValue->getValue();
                }
            }
        }

        return $default;
    }
981538
public function column($columns, $definition, $type)
    {
        if (is_null($columns)) {
            throw new \BadMethodCallException('Column cannot be empty.');
        }

        if (is_array($columns)) {
            $column = $columnKey = $columnValue = '';
            $i = 0;
            $arrCount = count($columns);

            foreach ($columns as $key => $value) {
                if (trim($type) == 'drop') {
                    $columnKey = '';
                    $columnValue = "`$value`";
                    $column .= strtoupper(trim($type)).' '.$columnKey.' '.$columnValue;
                }

                if (trim($type) == 'add') {
                    $columnKey = $key;
                    $columnValue = strtoupper($value);
                    $column .= strtoupper($type).' ('.$columnKey.' '.$columnValue.')';
                }

                $comma = ($i < $arrCount - 1) ? ',' : '';

                $column .= $comma;

                $i++;
            }

            $this->schema = self::ALTER_TABLE.'`'.$this->database.'`.`'.$this->tableName.'`
            '.$column.';';
        }

        if (is_string($columns)
            && $definition != null
        ) {
            /** @var $definition TYPE_NAME */
            $definition = (trim($type) == 'drop') ? '' : strtoupper($definition);

            $this->schema = self::ALTER_TABLE.'`'.$this->database.'`.`'.$this->tableName.'`
            '.strtoupper($type).' `'.$columns.'` '.$definition.';';
        }

        return $this;
    }
232668
protected function _normalizeTableColumns($columns)
    {
        $_defaults = [
            'get' => false,
            'before' => '',
            'after' => '',
        ];
        $result = [];

        foreach ($columns as $name => $options) {
            if (is_array($options)) {
                $_defaults['get'] = $name;
                $result[$name] = array_merge($_defaults, $options);
            } else {
                $_defaults['get'] = $options;
                $result[$options] = $_defaults;
            }
        }
        return $result;
    }
921808
private function getColumnByIndex(array $columns, int $index):? Column
    {
        $currentIndex = $index;

        if (!array_key_exists($currentIndex, $columns) && $currentIndex > 0) {
            $currentIndex = ($currentIndex % count($columns));
        }

        if (array_key_exists($currentIndex, $columns)) {
            return $columns[$currentIndex];
        }

        return null;
    }
998985
public function addIndex($columns, array $options = [])
    {
        $action = AddIndex::build($this->table, $columns, $options);
        $this->actions->addAction($action);

        return $this;
    }
143700
public function key($type, $columns, $name)
		{
			$parameters = array('name' => $name, 'columns' => (array) $columns);

			return $this->command($type, $parameters);
		}
445705
protected function indexCommand($type, $columns, $index)
    {
        $columns = (array) $columns;

        // If no name was specified for this index, we will create one using a basic
        // convention of the table name, followed by the columns, followed by an
        // index type, such as primary or index, which makes the index unique.
        if (is_null($index)) {
            $index = $this->createIndexName($type, $columns);
        }

        return $this->addCommand($type, compact('index', 'columns'));
    }