| @@ 69-77 (lines=9) @@ | ||
| 66 | ||
| 67 | $table = $schema->getTable($tableName); |
|
| 68 | if (!$table->hasIndex($indexName)) { |
|
| 69 | if ($this->connection->getDatabasePlatform()->getName() == "mysql" && !empty($length)) { |
|
| 70 | $cols = array(); |
|
| 71 | foreach ($length as $column => $len) { |
|
| 72 | $cols[] = sprintf('%s(%d)', $column, $len); |
|
| 73 | } |
|
| 74 | $this->addSql('CREATE INDEX '.$indexName.' ON '.$tableName.'('.implode(', ', $cols).');'); |
|
| 75 | } else { |
|
| 76 | $table->addIndex($columns, $indexName); |
|
| 77 | } |
|
| 78 | return true; |
|
| 79 | } |
|
| 80 | return false; |
|
| @@ 49-59 (lines=11) @@ | ||
| 46 | if ($table->hasIndex($indexName)) { |
|
| 47 | $this->dropIndex($schema, $tableName, $indexName); |
|
| 48 | } |
|
| 49 | if (!$table->hasIndex($indexName)) { |
|
| 50 | if ($this->connection->getDatabasePlatform()->getName() == "mysql" && !empty($length)) { |
|
| 51 | $cols = array(); |
|
| 52 | foreach ($length as $column => $len) { |
|
| 53 | $cols[] = sprintf('%s(%d)', $column, $len); |
|
| 54 | } |
|
| 55 | $this->addSql('CREATE INDEX '.$indexName.' ON '.$tableName.'('.implode(', ', $cols).');'); |
|
| 56 | } else { |
|
| 57 | $table->addIndex($columns, $indexName); |
|
| 58 | } |
|
| 59 | } |
|
| 60 | return true; |
|
| 61 | } |
|
| 62 | ||