Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #252 - Build command fails when using Postgres #253

Open
wants to merge 2 commits into
base: 0.8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Content/Infrastructure/Doctrine/MetadataLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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)) {
Expand Down Expand Up @@ -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']);
}
}

Expand Down Expand Up @@ -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);
}
Expand Down
12 changes: 6 additions & 6 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,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);
Comment on lines +120 to +125
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not edit the old UPGRADE this need be part of a new upgrade migrating existing idx_dimension to idx_your_entity>_...

```

## 0.6.0
Expand Down