Skip to content

Commit

Permalink
Update index naming for compatibility (sulu#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajdinmore committed Jun 6, 2023
1 parent 8fddedc commit dee03eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
13 changes: 7 additions & 6 deletions Content/Infrastructure/Doctrine/MetadataLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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)) {
Expand Down Expand Up @@ -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']);
}
}

Expand Down Expand Up @@ -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);
}
Expand Down
12 changes: 6 additions & 6 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ ALTER TABLE <your_entity>_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 <your_entity>_content (stage, locale);
CREATE INDEX idx_locale ON <your_entity>_content (locale);
CREATE INDEX idx_stage ON <your_entity>_content (stage);
CREATE INDEX idx_template_key ON <your_entity>_content (templateKey);
CREATE INDEX idx_workflow_place ON <your_entity>_content (workflowPlace);
CREATE INDEX idx_workflow_published ON <your_entity>_content (workflowPublished);
CREATE INDEX idx_<your_entity>_dimension ON <your_entity>_content (stage, locale);
CREATE INDEX idx_<your_entity>_locale ON <your_entity>_content (locale);
CREATE INDEX idx_<your_entity>_stage ON <your_entity>_content (stage);
CREATE INDEX idx_<your_entity>_template_key ON <your_entity>_content (templateKey);
CREATE INDEX idx_<your_entity>_workflow_place ON <your_entity>_content (workflowPlace);
CREATE INDEX idx_<your_entity>_workflow_published ON <your_entity>_content (workflowPublished);
```

## 0.6.0
Expand Down

0 comments on commit dee03eb

Please sign in to comment.