|
9 | 9 | use Doctrine\DBAL\Schema\AbstractSchemaManager; |
10 | 10 | use Doctrine\DBAL\Schema\Index; |
11 | 11 | use Doctrine\DBAL\Schema\SchemaException; |
| 12 | +use Doctrine\DBAL\Schema\Sequence; |
12 | 13 | use Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets; |
13 | 14 | use Doctrine\ORM\EntityManagerInterface; |
14 | 15 | use Doctrine\ORM\Mapping\ClassMetadata; |
@@ -226,10 +227,11 @@ static function (ClassMetadata $class) use ($idMapping): bool { |
226 | 227 |
|
227 | 228 | if (isset($class->table['uniqueConstraints'])) { |
228 | 229 | foreach ($class->table['uniqueConstraints'] as $indexName => $indexData) { |
229 | | - $uniqIndex = new Index($indexName, $this->getIndexColumns($class, $indexData), true, false, [], $indexData['options'] ?? []); |
| 230 | + $uniqIndex = new Index('tmp__' . $indexName, $this->getIndexColumns($class, $indexData), true, false, [], $indexData['options'] ?? []); |
230 | 231 |
|
231 | 232 | foreach ($table->getIndexes() as $tableIndexName => $tableIndex) { |
232 | | - if ($tableIndex->isFullfilledBy($uniqIndex)) { |
| 233 | + $method = method_exists($tableIndex, 'isFulfilledBy') ? 'isFulfilledBy' : 'isFullfilledBy'; |
| 234 | + if ($tableIndex->$method($uniqIndex)) { |
233 | 235 | $table->dropIndex($tableIndexName); |
234 | 236 |
|
235 | 237 | break; |
@@ -270,16 +272,23 @@ static function (ClassMetadata $class) use ($idMapping): bool { |
270 | 272 | $this->gatherEnumTypes($class, $schema); |
271 | 273 | } |
272 | 274 |
|
| 275 | + if (!$this->platform->supportsSchemas()) { |
| 276 | + $filter = /** @param Sequence|Table $asset */ static function ($asset) use ($schema): bool { |
| 277 | + return !$asset->isInDefaultNamespace($schema->getName()); |
| 278 | + }; |
| 279 | + |
| 280 | + if (array_filter($schema->getSequences() + $schema->getTables(), $filter) && !$this->platform->canEmulateSchemas()) { |
| 281 | + $schema->visit(new RemoveNamespacedAssets()); |
| 282 | + } |
| 283 | + } |
| 284 | + |
| 285 | + // remove default namespace creation from down migration |
273 | 286 | foreach ($this->schemaManager->getExistingSchemaSearchPaths() as $namespace) { |
274 | 287 | if (!$schema->hasNamespace($namespace)) { |
275 | 288 | $schema->createNamespace($namespace); |
276 | 289 | } |
277 | 290 | } |
278 | 291 |
|
279 | | - if (!$this->platform->supportsSchemas() && !$this->platform->canEmulateSchemas()) { |
280 | | - $schema->visit(new RemoveNamespacedAssets()); |
281 | | - } |
282 | | - |
283 | 292 | if ($eventManager->hasListeners(ToolEvents::postGenerateSchema)) { |
284 | 293 | $eventManager->dispatchEvent( |
285 | 294 | ToolEvents::postGenerateSchema, |
@@ -412,7 +421,7 @@ private function gatherColumnOptions(array $mapping): array |
412 | 421 | } |
413 | 422 |
|
414 | 423 | $options = array_intersect_key($mappingOptions, array_flip(self::KNOWN_COLUMN_OPTIONS)); |
415 | | - $options['customSchemaOptions'] = array_diff_key($mappingOptions, $options); |
| 424 | + $options['platformOptions'] = array_diff_key($mappingOptions, $options); |
416 | 425 |
|
417 | 426 | return $options; |
418 | 427 | } |
@@ -689,6 +698,7 @@ private function addDiscriminatorColumnDefinition(ClassMetadata $class, Table $t |
689 | 698 | $options['columnDefinition'] = $discrColumn['columnDefinition']; |
690 | 699 | } |
691 | 700 |
|
| 701 | + $options = $this->gatherColumnOptions($discrColumn) + $options; |
692 | 702 | $table->addColumn($discrColumn['name'], $discrColumn['type'], $options); |
693 | 703 | } |
694 | 704 |
|
|
0 commit comments