25 lines
875 B
PHP
25 lines
875 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Phinx\Migration\AbstractMigration;
|
|
|
|
final class CreateAuditLog extends AbstractMigration
|
|
{
|
|
public function change(): void
|
|
{
|
|
$table = $this->table('audit_log');
|
|
$table
|
|
->addColumn('user_id', 'string', ['limit' => 36, 'null' => true])
|
|
->addColumn('action', 'string', ['limit' => 100, 'null' => false])
|
|
->addColumn('entity_type', 'string', ['limit' => 50, 'null' => true])
|
|
->addColumn('entity_id', 'string', ['limit' => 36, 'null' => true])
|
|
->addColumn('details_json', 'text', ['null' => true])
|
|
->addColumn('created_at', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP'])
|
|
->addIndex(['action'])
|
|
->addIndex(['entity_type', 'entity_id'])
|
|
->addIndex(['created_at'])
|
|
->create();
|
|
}
|
|
}
|