diff --git a/composer.json b/composer.json index 6a63dac..62955bc 100644 --- a/composer.json +++ b/composer.json @@ -33,6 +33,7 @@ } }, "require-dev": { + "ext-pdo": "*", "doctrine/data-fixtures": "^1.5.3", "gedmo/doctrine-extensions": "^3.0", "phpunit/phpunit": "^11.0", diff --git a/src/Provider/Doctrine/Persistence/Helper/SchemaHelper.php b/src/Provider/Doctrine/Persistence/Helper/SchemaHelper.php index 0294d4f..1589a63 100644 --- a/src/Provider/Doctrine/Persistence/Helper/SchemaHelper.php +++ b/src/Provider/Doctrine/Persistence/Helper/SchemaHelper.php @@ -13,7 +13,7 @@ abstract class SchemaHelper * * @return array{id: array{type: string, options: array{autoincrement: true, unsigned: true}}, type: array{type: string, options: array{notnull: true, length: int}}, object_id: array{type: string, options: array{notnull: true}}, discriminator: array{type: string, options: array{default: null, notnull: false}}, transaction_hash: array{type: string, options: array{notnull: false, length: int}}, diffs: array{type: string, options: array{default: null, notnull: false}}, blame_id: array{type: string, options: array{default: null, notnull: false}}, blame_user: array{type: string, options: array{default: null, notnull: false, length: int}}, blame_user_fqdn: array{type: string, options: array{default: null, notnull: false, length: int}}, blame_user_firewall: array{type: string, options: array{default: null, notnull: false, length: int}}, ip: array{type: string, options: array{default: null, notnull: false, length: int}}, created_at: array{type: string, options: array{notnull: true}}} */ - public static function getAuditTableColumns(): array + public static function getAuditTableColumns(array $defaultTableOptions = []): array { return [ 'id' => [ @@ -28,6 +28,7 @@ public static function getAuditTableColumns(): array 'options' => [ 'notnull' => true, 'length' => 10, + 'platformOptions' => $defaultTableOptions, ], ], 'object_id' => [ @@ -35,6 +36,7 @@ public static function getAuditTableColumns(): array 'options' => [ 'notnull' => true, 'length' => 255, + 'platformOptions' => $defaultTableOptions, ], ], 'discriminator' => [ @@ -43,6 +45,7 @@ public static function getAuditTableColumns(): array 'default' => null, 'notnull' => false, 'length' => 255, + 'platformOptions' => $defaultTableOptions, ], ], 'transaction_hash' => [ @@ -50,6 +53,7 @@ public static function getAuditTableColumns(): array 'options' => [ 'notnull' => false, 'length' => 40, + 'platformOptions' => $defaultTableOptions, ], ], 'diffs' => [ @@ -65,6 +69,7 @@ public static function getAuditTableColumns(): array 'default' => null, 'notnull' => false, 'length' => 255, + 'platformOptions' => $defaultTableOptions, ], ], 'blame_user' => [ @@ -73,6 +78,7 @@ public static function getAuditTableColumns(): array 'default' => null, 'notnull' => false, 'length' => 255, + 'platformOptions' => $defaultTableOptions, ], ], 'blame_user_fqdn' => [ @@ -81,6 +87,7 @@ public static function getAuditTableColumns(): array 'default' => null, 'notnull' => false, 'length' => 255, + 'platformOptions' => $defaultTableOptions, ], ], 'blame_user_firewall' => [ @@ -89,6 +96,7 @@ public static function getAuditTableColumns(): array 'default' => null, 'notnull' => false, 'length' => 100, + 'platformOptions' => $defaultTableOptions, ], ], 'ip' => [ @@ -97,6 +105,7 @@ public static function getAuditTableColumns(): array 'default' => null, 'notnull' => false, 'length' => 45, + 'platformOptions' => $defaultTableOptions, ], ], 'created_at' => [ diff --git a/src/Provider/Doctrine/Persistence/Schema/SchemaManager.php b/src/Provider/Doctrine/Persistence/Schema/SchemaManager.php index 41dbb92..4b640dd 100644 --- a/src/Provider/Doctrine/Persistence/Schema/SchemaManager.php +++ b/src/Provider/Doctrine/Persistence/Schema/SchemaManager.php @@ -171,7 +171,7 @@ public function createAuditTable(string $entity, ?Schema $schema = null): Schema // Add columns to audit table $isJsonSupported = PlatformHelper::isJsonSupported($connection); - foreach (SchemaHelper::getAuditTableColumns() as $columnName => $struct) { + foreach (SchemaHelper::getAuditTableColumns($connection->getParams()['defaultTableOptions'] ?? []) as $columnName => $struct) { if (Types::JSON === $struct['type'] && !$isJsonSupported) { $type = Types::TEXT; } else { @@ -226,7 +226,7 @@ public function updateAuditTable(string $entity, ?Schema $schema = null): Schema $table = $schema->getTable($auditTablename); // process columns - $this->processColumns($table, $table->getColumns(), SchemaHelper::getAuditTableColumns(), $connection); + $this->processColumns($table, $table->getColumns(), SchemaHelper::getAuditTableColumns($connection->getParams()['defaultTableOptions'] ?? []), $connection); // process indices $this->processIndices($table, SchemaHelper::getAuditTableIndices($auditTablename), $connection);