Skip to content

Commit

Permalink
Merge branch 'feature/saterday-night-fixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvdlinde committed Oct 21, 2024
2 parents 933422f + f8f211a commit 2a84753
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/Db/AuditTrail.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
class AuditTrail extends Entity implements JsonSerializable
{
protected ?string $uuid = null;
protected ?int $schema = null;
protected ?int $register = null;
protected ?int $object = null;
protected ?string $action = null;
protected ?array $changed = null;
Expand All @@ -17,10 +19,13 @@ class AuditTrail extends Entity implements JsonSerializable
protected ?string $session = null;
protected ?string $request = null;
protected ?string $ipAddress = null;
protected ?string $version = null;
protected ?DateTime $created = null;

public function __construct() {
$this->addType(fieldName: 'uuid', type: 'string');
$this->addType(fieldName: 'schema', type: 'integer');
$this->addType(fieldName: 'register', type: 'integer');
$this->addType(fieldName: 'object', type: 'integer');
$this->addType(fieldName: 'action', type: 'string');
$this->addType(fieldName: 'changed', type: 'json');
Expand All @@ -29,6 +34,7 @@ public function __construct() {
$this->addType(fieldName: 'session', type: 'string');
$this->addType(fieldName: 'request', type: 'string');
$this->addType(fieldName: 'ipAddress', type: 'string');
$this->addType(fieldName: 'version', type: 'string');
$this->addType(fieldName: 'created', type: 'datetime');
}

Expand Down Expand Up @@ -66,6 +72,8 @@ public function jsonSerialize(): array
return [
'id' => $this->id,
'uuid' => $this->uuid,
'schema' => $this->schema,
'register' => $this->register,
'object' => $this->object,
'action' => $this->action,
'changed' => $this->changed,
Expand All @@ -74,6 +82,7 @@ public function jsonSerialize(): array
'session' => $this->session,
'request' => $this->request,
'ipAddress' => $this->ipAddress,
'version' => $this->version,
'created' => isset($this->created) ? $this->created->format('c') : null
];
}
Expand Down
3 changes: 3 additions & 0 deletions lib/Migration/Version1Date20241020231700.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
$table = $schema->createTable('openregister_audit_trails');
$table->addColumn('id', Types::INTEGER, ['autoincrement' => true, 'notnull' => true]);
$table->addColumn('uuid', Types::STRING, ['notnull' => false, 'length' => 255]);
$table->addColumn('schema', Types::INTEGER, ['notnull' => false]);
$table->addColumn('regsiter', Types::INTEGER, ['notnull' => false]);
$table->addColumn('object', Types::INTEGER, ['notnull' => true]);
$table->addColumn('action', Types::STRING, ['notnull' => true, 'default' => 'update']);
$table->addColumn('changed', Types::JSON, ['notnull' => true]);
Expand All @@ -48,6 +50,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
$table->addColumn('session', Types::STRING, ['notnull' => true, 'length' => 255]);
$table->addColumn('request', Types::STRING, ['notnull' => false, 'length' => 255]);
$table->addColumn('ip_address', Types::STRING, ['notnull' => false, 'length' => 255]);
$table->addColumn('version', Types::STRING, ['notnull' => false, 'length' => 255]);
$table->addColumn('created', Types::DATETIME, ['notnull' => true]);

$table->setPrimaryKey(['id']);
Expand Down

0 comments on commit 2a84753

Please sign in to comment.