/** * @param \Doctrine\ORM\Tools\Event\SchemaIndexDefinitionEventArgs $args */ public function onSchemaIndexDefinition(SchemaIndexDefinitionEventArgs $args) { $index = $args->getTableIndex(); if (0 === stripos($index['name'], 'spatialidx_')) { $args->preventDefault(); } }
/** * Handles the Doctrine schema and overrides the indexes with a fixed length. * * @param SchemaIndexDefinitionEventArgs $event */ public function onSchemaIndexDefinition(SchemaIndexDefinitionEventArgs $event) { $connection = $event->getConnection(); $data = $event->getTableIndex(); if (!$connection->getDatabasePlatform() instanceof MySqlPlatform || 'PRIMARY' === $data['name']) { return; } $index = $connection->fetchAssoc(sprintf("SHOW INDEX FROM %s WHERE Key_name='%s'", $event->getTable(), $data['name'])); if (null !== $index['Sub_part']) { $columns = []; foreach ($data['columns'] as $col) { $columns[$col] = sprintf('%s(%s)', $col, $index['Sub_part']); } $event->setIndex(new Index($data['name'], $columns, $data['unique'], $data['primary'], $data['flags'], $data['options'])); $event->preventDefault(); } }