yii\db\Command::createIndex PHP Method

createIndex() public method

Creates a SQL command for creating a new index.
public createIndex ( string $name, string $table, string | array $columns, boolean $unique = false )
$name string the name of the index. The name will be properly quoted by the method.
$table string the table that the new index will be created for. The table name will be properly quoted by the method.
$columns string | array the column(s) that should be included in the index. If there are multiple columns, please separate them by commas. The column names will be properly quoted by the method.
$unique boolean whether to add UNIQUE constraint on the created index.
    public function createIndex($name, $table, $columns, $unique = false)
    {
        $sql = $this->db->getQueryBuilder()->createIndex($name, $table, $columns, $unique);
        return $this->setSql($sql);
    }