-
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TASK: Core and neos schemas for pgsql and mysql
Related: #3855 Extends the ideas of the DbalSchemaFactory and provides separate implementations for MySql/MariaDB and PostgreSQL, allowing all core tables to be created on both platforms.
- Loading branch information
Showing
7 changed files
with
136 additions
and
101 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
namespace Neos\ContentGraph\DoctrineDbalAdapter; | ||
|
||
use Doctrine\DBAL\Connection; | ||
use Doctrine\DBAL\Exception as DBALException; | ||
use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
use Doctrine\DBAL\Schema\AbstractSchemaManager; | ||
|
@@ -19,8 +20,6 @@ | |
*/ | ||
class DoctrineDbalContentGraphSchemaBuilder | ||
{ | ||
private const DEFAULT_TEXT_COLLATION = 'utf8mb4_unicode_520_ci'; | ||
|
||
public function __construct( | ||
private readonly ContentGraphTableNames $tableNames | ||
) { | ||
|
@@ -30,27 +29,27 @@ public function __construct( | |
* @param AbstractSchemaManager<AbstractPlatform> $schemaManager | ||
* @return Schema | ||
*/ | ||
public function buildSchema(AbstractSchemaManager $schemaManager): Schema | ||
public function buildSchema(Connection $connection): Schema | ||
Check failure on line 32 in Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphSchemaBuilder.php GitHub Actions / PHP 8.2 Test linting-unit-functionaltests-mysql (deps: highest)
Check failure on line 32 in Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphSchemaBuilder.php GitHub Actions / PHP 8.3 Test linting-unit-functionaltests-mysql (deps: highest)
|
||
{ | ||
return DbalSchemaFactory::createSchemaWithTables($schemaManager, [ | ||
$this->createNodeTable(), | ||
$this->createHierarchyRelationTable(), | ||
$this->createReferenceRelationTable(), | ||
$this->createDimensionSpacePointsTable(), | ||
$this->createWorkspaceTable(), | ||
$this->createContentStreamTable(), | ||
return DbalSchemaFactory::createSchemaWithTables($connection, [ | ||
$this->createNodeTable($connection->getDatabasePlatform()), | ||
$this->createHierarchyRelationTable($connection->getDatabasePlatform()), | ||
$this->createReferenceRelationTable($connection->getDatabasePlatform()), | ||
$this->createDimensionSpacePointsTable($connection->getDatabasePlatform()), | ||
$this->createWorkspaceTable($connection->getDatabasePlatform()), | ||
$this->createContentStreamTable($connection->getDatabasePlatform()), | ||
]); | ||
} | ||
|
||
private function createNodeTable(): Table | ||
private function createNodeTable(AbstractPlatform $platform): Table | ||
{ | ||
$table = self::createTable($this->tableNames->node(), [ | ||
DbalSchemaFactory::columnForNodeAnchorPoint('relationanchorpoint')->setAutoincrement(true), | ||
DbalSchemaFactory::columnForNodeAggregateId('nodeaggregateid')->setNotnull(false), | ||
DbalSchemaFactory::columnForDimensionSpacePointHash('origindimensionspacepointhash')->setNotnull(false), | ||
DbalSchemaFactory::columnForNodeTypeName('nodetypename'), | ||
(new Column('name', self::type(Types::STRING)))->setLength(255)->setNotnull(false)->setPlatformOption('charset', 'ascii')->setPlatformOption('collation', 'ascii_general_ci'), | ||
(new Column('properties', self::type(Types::TEXT)))->setNotnull(true)->setPlatformOption('collation', self::DEFAULT_TEXT_COLLATION), | ||
DbalSchemaFactory::columnForNodeAnchorPoint('relationanchorpoint', $platform)->setAutoincrement(true), | ||
DbalSchemaFactory::columnForNodeAggregateId('nodeaggregateid', $platform)->setNotnull(false), | ||
DbalSchemaFactory::columnForDimensionSpacePointHash('origindimensionspacepointhash', $platform)->setNotnull(false), | ||
DbalSchemaFactory::columnForNodeTypeName('nodetypename', $platform), | ||
(new Column('name', self::type(Types::STRING)))->setLength(255)->setNotnull(false), | ||
(new Column('properties', self::type(Types::JSON)))->setNotnull(true), | ||
(new Column('classification', self::type(Types::BINARY)))->setLength(20)->setNotnull(true), | ||
(new Column('created', self::type(Types::DATETIME_IMMUTABLE)))->setDefault('CURRENT_TIMESTAMP')->setNotnull(true), | ||
(new Column('originalcreated', self::type(Types::DATETIME_IMMUTABLE)))->setDefault('CURRENT_TIMESTAMP')->setNotnull(true), | ||
|
@@ -64,14 +63,14 @@ private function createNodeTable(): Table | |
->addIndex(['nodetypename']); | ||
} | ||
|
||
private function createHierarchyRelationTable(): Table | ||
private function createHierarchyRelationTable(AbstractPlatform $platform): Table | ||
{ | ||
$table = self::createTable($this->tableNames->hierarchyRelation(), [ | ||
(new Column('position', self::type(Types::INTEGER)))->setNotnull(true), | ||
DbalSchemaFactory::columnForContentStreamId('contentstreamid')->setNotnull(true), | ||
DbalSchemaFactory::columnForDimensionSpacePointHash('dimensionspacepointhash')->setNotnull(true), | ||
DbalSchemaFactory::columnForNodeAnchorPoint('parentnodeanchor'), | ||
DbalSchemaFactory::columnForNodeAnchorPoint('childnodeanchor'), | ||
DbalSchemaFactory::columnForContentStreamId('contentstreamid', $platform)->setNotnull(true), | ||
DbalSchemaFactory::columnForDimensionSpacePointHash('dimensionspacepointhash', $platform)->setNotnull(true), | ||
DbalSchemaFactory::columnForNodeAnchorPoint('parentnodeanchor', $platform), | ||
DbalSchemaFactory::columnForNodeAnchorPoint('childnodeanchor', $platform), | ||
(new Column('subtreetags', self::type(Types::JSON))), | ||
]); | ||
|
||
|
@@ -84,50 +83,50 @@ private function createHierarchyRelationTable(): Table | |
->addIndex(['contentstreamid', 'dimensionspacepointhash']); | ||
} | ||
|
||
private function createDimensionSpacePointsTable(): Table | ||
private function createDimensionSpacePointsTable(AbstractPlatform $platform): Table | ||
{ | ||
$table = self::createTable($this->tableNames->dimensionSpacePoints(), [ | ||
DbalSchemaFactory::columnForDimensionSpacePointHash('hash')->setNotnull(true), | ||
DbalSchemaFactory::columnForDimensionSpacePoint('dimensionspacepoint')->setNotnull(true) | ||
DbalSchemaFactory::columnForDimensionSpacePointHash('hash', $platform)->setNotnull(true), | ||
DbalSchemaFactory::columnForDimensionSpacePoint('dimensionspacepoint', $platform)->setNotnull(true) | ||
]); | ||
|
||
return $table | ||
->setPrimaryKey(['hash']); | ||
} | ||
|
||
private function createReferenceRelationTable(): Table | ||
private function createReferenceRelationTable(AbstractPlatform $platform): Table | ||
{ | ||
$table = self::createTable($this->tableNames->referenceRelation(), [ | ||
(new Column('name', self::type(Types::STRING)))->setLength(255)->setNotnull(true)->setPlatformOption('charset', 'ascii')->setPlatformOption('collation', 'ascii_general_ci'), | ||
(new Column('name', self::type(Types::STRING)))->setLength(255)->setNotnull(true), | ||
(new Column('position', self::type(Types::INTEGER)))->setNotnull(true), | ||
DbalSchemaFactory::columnForNodeAnchorPoint('nodeanchorpoint'), | ||
(new Column('properties', self::type(Types::TEXT)))->setNotnull(false)->setPlatformOption('collation', self::DEFAULT_TEXT_COLLATION), | ||
DbalSchemaFactory::columnForNodeAggregateId('destinationnodeaggregateid')->setNotnull(true) | ||
DbalSchemaFactory::columnForNodeAnchorPoint('nodeanchorpoint', $platform), | ||
(new Column('properties', self::type(Types::JSON)))->setNotnull(false), | ||
DbalSchemaFactory::columnForNodeAggregateId('destinationnodeaggregateid', $platform)->setNotnull(true) | ||
]); | ||
|
||
return $table | ||
->setPrimaryKey(['name', 'position', 'nodeanchorpoint']); | ||
} | ||
|
||
private function createWorkspaceTable(): Table | ||
private function createWorkspaceTable(AbstractPlatform $platform): Table | ||
{ | ||
$workspaceTable = self::createTable($this->tableNames->workspace(), [ | ||
DbalSchemaFactory::columnForWorkspaceName('name')->setNotnull(true), | ||
DbalSchemaFactory::columnForWorkspaceName('baseWorkspaceName')->setNotnull(false), | ||
DbalSchemaFactory::columnForContentStreamId('currentContentStreamId')->setNotNull(true), | ||
DbalSchemaFactory::columnForWorkspaceName('name', $platform)->setNotnull(true), | ||
DbalSchemaFactory::columnForWorkspaceName('baseWorkspaceName', $platform)->setNotnull(false), | ||
DbalSchemaFactory::columnForContentStreamId('currentContentStreamId', $platform)->setNotNull(true), | ||
]); | ||
|
||
$workspaceTable->addUniqueIndex(['currentContentStreamId']); | ||
|
||
return $workspaceTable->setPrimaryKey(['name']); | ||
} | ||
|
||
private function createContentStreamTable(): Table | ||
private function createContentStreamTable(AbstractPlatform $platform): Table | ||
{ | ||
$contentStreamTable = self::createTable($this->tableNames->contentStream(), [ | ||
DbalSchemaFactory::columnForContentStreamId('id')->setNotnull(true), | ||
DbalSchemaFactory::columnForContentStreamId('id', $platform)->setNotnull(true), | ||
(new Column('version', Type::getType(Types::INTEGER)))->setNotnull(true), | ||
DbalSchemaFactory::columnForContentStreamId('sourceContentStreamId')->setNotnull(false), | ||
DbalSchemaFactory::columnForContentStreamId('sourceContentStreamId', $platform)->setNotnull(false), | ||
(new Column('sourceContentStreamVersion', Type::getType(Types::INTEGER)))->setNotnull(false), | ||
(new Column('closed', Type::getType(Types::BOOLEAN)))->setNotnull(true), | ||
(new Column('hasChanges', Type::getType(Types::BOOLEAN)))->setNotnull(true), | ||
|
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
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.