From dee03ebc5ec4a013ddc6580c6bf696f003ca97f7 Mon Sep 17 00:00:00 2001 From: Andrew Dinmore Date: Tue, 6 Jun 2023 17:17:39 +0100 Subject: [PATCH] Update index naming for compatibility (#252) --- Content/Infrastructure/Doctrine/MetadataLoader.php | 13 +++++++------ UPGRADE.md | 12 ++++++------ 2 files changed, 13 insertions(+), 12 deletions(-) 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