diff --git a/src/EventListener/CreateSchemaListener.php b/src/EventListener/CreateSchemaListener.php index 500382d0..1b99f5a6 100644 --- a/src/EventListener/CreateSchemaListener.php +++ b/src/EventListener/CreateSchemaListener.php @@ -14,6 +14,7 @@ namespace SimpleThings\EntityAudit\EventListener; use Doctrine\Common\EventSubscriber; +use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Types; @@ -83,10 +84,13 @@ public function postGenerateSchemaTable(GenerateSchemaTableEventArgs $eventArgs) ); foreach ($entityTable->getColumns() as $column) { - $revisionTable->addColumn($column->getName(), $column->getType()->getName(), array_merge( - $column->toArray(), - ['notnull' => false, 'autoincrement' => false] - )); + $columnOptions = array_filter($column->toArray(), static function($columnOption, $columnKey) { + return method_exists(Column::class, 'set'.$columnKey); + }, ARRAY_FILTER_USE_BOTH); + $columnOptions['notnull'] = false; + $columnOptions['autoincrement'] = false; + + $revisionTable->addColumn($column->getName(), $column->getType()->getName(), $columnOptions); } $revisionTable->addColumn($this->config->getRevisionFieldName(), $this->config->getRevisionIdFieldType()); $revisionTable->addColumn($this->config->getRevisionTypeFieldName(), Types::STRING, ['length' => 4]);