Commit 2ea50ee7 authored by Juozas Kaziukenas's avatar Juozas Kaziukenas

Fixed createTable() method to correctly create indexes

parent 6d79c6d6
...@@ -152,6 +152,48 @@ DROP DATABASE ' . $name . ';'; ...@@ -152,6 +152,48 @@ DROP DATABASE ' . $name . ';';
/** /**
* @override * @override
*/
protected function _getCreateTableSQL($tableName, array $columns, array $options = array())
{
$columnListSql = $this->getColumnDeclarationListSQL($columns);
if (isset($options['uniqueConstraints']) && ! empty($options['uniqueConstraints'])) {
foreach ($options['uniqueConstraints'] as $name => $definition) {
$columnListSql .= ', ' . $this->getUniqueConstraintDeclarationSQL($name, $definition);
}
}
if (isset($options['primary']) && ! empty($options['primary'])) {
$columnListSql .= ', PRIMARY KEY(' . implode(', ', array_unique(array_values($options['primary']))) . ')';
}
$query = 'CREATE TABLE ' . $tableName . ' (' . $columnListSql;
$check = $this->getCheckDeclarationSQL($columns);
if ( ! empty($check)) {
$query .= ', ' . $check;
}
$query .= ')';
$sql[] = $query;
if (isset($options['indexes']) && ! empty($options['indexes'])) {
foreach ($options['indexes'] AS $index) {
$sql[] = $this->getCreateIndexSQL($index, $tableName);
}
}
if (isset($options['foreignKeys'])) {
foreach ((array) $options['foreignKeys'] AS $definition) {
$sql[] = $this->getCreateForeignKeySQL($definition, $tableName);
}
}
return $sql;
}
/**
* @override
*/ */
public function getAlterTableSQL(TableDiff $diff) public function getAlterTableSQL(TableDiff $diff)
{ {
...@@ -613,15 +655,6 @@ DROP DATABASE ' . $name . ';'; ...@@ -613,15 +655,6 @@ DROP DATABASE ' . $name . ';';
return $this->getDateTimeFormatString(); return $this->getDateTimeFormatString();
} }
/**
* @override
*/
public function getIndexDeclarationSQL($name, Index $index)
{
// @todo
return $this->getUniqueConstraintDeclarationSQL($name, $index);
}
/** /**
* Get the platform name for this instance * Get the platform name for this instance
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment