Skip to content

Commit

Permalink
fixes #221 (#232)
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Andreyev <[email protected]>
  • Loading branch information
oleg-andreyev authored Nov 11, 2024
1 parent 8077b2d commit 2fd99aa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
}
},
"require-dev": {
"ext-pdo": "*",
"doctrine/data-fixtures": "^1.5.3",
"gedmo/doctrine-extensions": "^3.0",
"phpunit/phpunit": "^11.0",
Expand Down
11 changes: 10 additions & 1 deletion src/Provider/Doctrine/Persistence/Helper/SchemaHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand All @@ -28,13 +28,15 @@ public static function getAuditTableColumns(): array
'options' => [
'notnull' => true,
'length' => 10,
'platformOptions' => $defaultTableOptions,
],
],
'object_id' => [
'type' => Types::STRING,
'options' => [
'notnull' => true,
'length' => 255,
'platformOptions' => $defaultTableOptions,
],
],
'discriminator' => [
Expand All @@ -43,13 +45,15 @@ public static function getAuditTableColumns(): array
'default' => null,
'notnull' => false,
'length' => 255,
'platformOptions' => $defaultTableOptions,
],
],
'transaction_hash' => [
'type' => Types::STRING,
'options' => [
'notnull' => false,
'length' => 40,
'platformOptions' => $defaultTableOptions,
],
],
'diffs' => [
Expand All @@ -65,6 +69,7 @@ public static function getAuditTableColumns(): array
'default' => null,
'notnull' => false,
'length' => 255,
'platformOptions' => $defaultTableOptions,
],
],
'blame_user' => [
Expand All @@ -73,6 +78,7 @@ public static function getAuditTableColumns(): array
'default' => null,
'notnull' => false,
'length' => 255,
'platformOptions' => $defaultTableOptions,
],
],
'blame_user_fqdn' => [
Expand All @@ -81,6 +87,7 @@ public static function getAuditTableColumns(): array
'default' => null,
'notnull' => false,
'length' => 255,
'platformOptions' => $defaultTableOptions,
],
],
'blame_user_firewall' => [
Expand All @@ -89,6 +96,7 @@ public static function getAuditTableColumns(): array
'default' => null,
'notnull' => false,
'length' => 100,
'platformOptions' => $defaultTableOptions,
],
],
'ip' => [
Expand All @@ -97,6 +105,7 @@ public static function getAuditTableColumns(): array
'default' => null,
'notnull' => false,
'length' => 45,
'platformOptions' => $defaultTableOptions,
],
],
'created_at' => [
Expand Down
4 changes: 2 additions & 2 deletions src/Provider/Doctrine/Persistence/Schema/SchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 2fd99aa

Please sign in to comment.