diff --git a/Content/Infrastructure/Doctrine/MetadataLoader.php b/Content/Infrastructure/Doctrine/MetadataLoader.php index 83aa934d..9e290e32 100644 --- a/Content/Infrastructure/Doctrine/MetadataLoader.php +++ b/Content/Infrastructure/Doctrine/MetadataLoader.php @@ -47,9 +47,9 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $event): void $this->addField($metadata, 'stage', 'string', ['length' => 16, 'nullable' => false]); $this->addField($metadata, 'locale', 'string', ['length' => 7, 'nullable' => 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(SeoInterface::class)) { @@ -66,7 +66,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(ExcerptInterface::class)) { @@ -103,8 +103,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']); } } @@ -217,6 +217,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 c235fd66..f731af5e 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -17,12 +17,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