diff --git a/Content/Infrastructure/Doctrine/MetadataLoader.php b/Content/Infrastructure/Doctrine/MetadataLoader.php index ad58ef6c..74adaafb 100644 --- a/Content/Infrastructure/Doctrine/MetadataLoader.php +++ b/Content/Infrastructure/Doctrine/MetadataLoader.php @@ -55,9 +55,9 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $event): void $this->addField($metadata, 'locale', 'string', ['length' => 7, 'nullable' => true]); $this->addField($metadata, 'ghostLocale', 'string', ['length' => 7, 'nullable' => true]); $this->addField($metadata, 'availableLocales', 'json', ['nullable' => true, 'options' => ['jsonb' => true]]); - $this->addIndex($metadata, 'idx_dimension', ['stage', 'locale']); - $this->addIndex($metadata, 'idx_locale', ['locale']); - $this->addIndex($metadata, 'idx_stage', ['stage']); + $this->addIndex($metadata, 'dimension', ['stage', 'locale']); + $this->addIndex($metadata, 'locale', ['locale']); + $this->addIndex($metadata, 'stage', ['stage']); } if ($reflection->implementsInterface(ShadowInterface::class)) { @@ -69,7 +69,7 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $event): void $this->addField($metadata, 'templateKey', 'string', ['length' => 32]); $this->addField($metadata, 'templateData', 'json', ['nullable' => false, 'options' => ['jsonb' => true]]); - $this->addIndex($metadata, 'idx_template_key', ['templateKey']); + $this->addIndex($metadata, 'template_key', ['templateKey']); } if ($reflection->implementsInterface(SeoInterface::class)) { @@ -125,8 +125,8 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $event): void $this->addField($metadata, 'workflowPlace', 'string', ['length' => 32, 'nullable' => true]); $this->addField($metadata, 'workflowPublished', 'datetime_immutable', ['nullable' => true]); - $this->addIndex($metadata, 'idx_workflow_place', ['workflowPlace']); - $this->addIndex($metadata, 'idx_workflow_published', ['workflowPublished']); + $this->addIndex($metadata, 'workflow_place', ['workflowPlace']); + $this->addIndex($metadata, 'workflow_published', ['workflowPublished']); } } @@ -240,6 +240,7 @@ private function addField(ClassMetadataInfo $metadata, string $name, string $typ private function addIndex(ClassMetadataInfo $metadata, string $name, array $fields): void { $builder = new ClassMetadataBuilder($metadata); + $name = sprintf('idx_%s_%s', $metadata->getTableName(), $name); $builder->addIndex($fields, $name); } diff --git a/UPGRADE.md b/UPGRADE.md index 36726412..947f8d8a 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -117,12 +117,12 @@ ALTER TABLE _example_dimensions ALTER COLUMN templateData SET DATA Improve performance of the `*ContentDimension` tables with additional indexes for the database: ```sql -CREATE INDEX idx_dimension ON _content (stage, locale); -CREATE INDEX idx_locale ON _content (locale); -CREATE INDEX idx_stage ON _content (stage); -CREATE INDEX idx_template_key ON _content (templateKey); -CREATE INDEX idx_workflow_place ON _content (workflowPlace); -CREATE INDEX idx_workflow_published ON _content (workflowPublished); +CREATE INDEX idx__dimension ON _content (stage, locale); +CREATE INDEX idx__locale ON _content (locale); +CREATE INDEX idx__stage ON _content (stage); +CREATE INDEX idx__template_key ON _content (templateKey); +CREATE INDEX idx__workflow_place ON _content (workflowPlace); +CREATE INDEX idx__workflow_published ON _content (workflowPublished); ``` ## 0.6.0