-
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TASK: Deterministic projection schema with sensible defaults
Projections should be created with deterministic charset and collation and columns containing the same data should behave the same to have similar conditions between installations, therefore the configured charset/collation should be applied when creating projection schemas. This includes some additional optimizations for column definitions limiting the possible contents based on the currently existing limitations in the code. Fixes: #4729
- Loading branch information
Showing
10 changed files
with
203 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
Neos.ContentRepository.Core/Classes/Infrastructure/DbalSchemaFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
namespace Neos\ContentRepository\Core\Infrastructure; | ||
|
||
use Doctrine\DBAL\Schema\AbstractSchemaManager; | ||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\DBAL\Schema\Table; | ||
use Doctrine\DBAL\Types\Types; | ||
|
||
/** | ||
* Provide doctrine DBAL column schema definitions for common types in the content repository to | ||
* produce consistent columns across projections. | ||
* | ||
* @internal Because we might need to check for platform later on and generally change the input and output format of functions within. | ||
*/ | ||
final class DbalSchemaFactory | ||
{ | ||
public static function addColumnForNodeAggregateId(Table $table, string $columnName, bool $notNull): Table | ||
{ | ||
$table->addColumn($columnName, Types::STRING) | ||
->setLength(64) | ||
->setNotnull($notNull) | ||
->setCustomSchemaOption('charset', 'ascii') | ||
->setCustomSchemaOption('collation', 'ascii_general_ci'); | ||
|
||
return $table; | ||
} | ||
|
||
public static function addColumnForContentStreamId(Table $table, string $columnName, bool $notNull): Table | ||
{ | ||
$table->addColumn($columnName, Types::STRING) | ||
->setLength(36) | ||
->setNotnull($notNull) | ||
->setCustomSchemaOption('charset', 'binary'); | ||
|
||
return $table; | ||
} | ||
|
||
public static function addColumnForNodeAnchorPoint(Table $table, string $columnName): Table | ||
{ | ||
$table->addColumn($columnName, Types::BINARY) | ||
->setLength(36) | ||
->setNotnull(true); | ||
|
||
return $table; | ||
} | ||
|
||
public static function addColumnForDimensionSpacePoint(Table $table, string $columnName, bool $notNull): Table | ||
{ | ||
$table->addColumn($columnName, Types::TEXT) | ||
->setNotnull($notNull) | ||
->setDefault('{}') | ||
->setCustomSchemaOption('collation', 'utf8mb4_unicode_520_ci'); | ||
|
||
return $table; | ||
} | ||
|
||
public static function addColumnForDimensionSpacePointHash(Table $table, string $columnName, bool $notNull): Table | ||
{ | ||
$table->addColumn($columnName, Types::BINARY) | ||
->setLength(32) | ||
->setDefault('') | ||
->setNotnull($notNull); | ||
|
||
return $table; | ||
} | ||
|
||
public static function addColumnForNodeTypeName(Table $table, string $columnName): Table | ||
{ | ||
$table->addColumn($columnName, Types::STRING) | ||
->setLength(255) | ||
->setNotnull(true) | ||
->setCustomSchemaOption('charset', 'ascii') | ||
->setCustomSchemaOption('collation', 'ascii_general_ci'); | ||
|
||
return $table; | ||
} | ||
|
||
public static function createEmptySchema(AbstractSchemaManager $schemaManager): Schema | ||
{ | ||
$schemaConfig = $schemaManager->createSchemaConfig(); | ||
$schemaConfig->setDefaultTableOptions([ | ||
'charset' => 'utf8mb4' | ||
]); | ||
|
||
return new Schema([], [], $schemaConfig); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.