Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
| Numéro du ticket | Titre du ticket | |------------------|-----------------| | | | ## Description de la PR ## Modification du .env ## Check list - [ ] Pas de régression - [ ] TU/TI/TF rédigée - [ ] TU/TI/TF OK - [ ] CHANGELOG modifié Reviewed-on: #9 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
44 lines
1.5 KiB
PHP
44 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
final class Version20260330120000 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Create audit_logs table for tracking user actions.';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->addSql('CREATE TABLE audit_logs (
|
|
id SERIAL PRIMARY KEY,
|
|
employee_id INTEGER DEFAULT NULL,
|
|
username VARCHAR(180) NOT NULL,
|
|
action VARCHAR(30) NOT NULL,
|
|
entity_type VARCHAR(50) NOT NULL,
|
|
entity_id INTEGER DEFAULT NULL,
|
|
description TEXT NOT NULL,
|
|
changes JSON DEFAULT NULL,
|
|
affected_date DATE DEFAULT NULL,
|
|
created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL,
|
|
CONSTRAINT fk_audit_employee FOREIGN KEY (employee_id) REFERENCES employees (id) ON DELETE SET NULL
|
|
)');
|
|
|
|
$this->addSql('CREATE INDEX idx_audit_employee_created ON audit_logs (employee_id, created_at)');
|
|
$this->addSql('CREATE INDEX idx_audit_entity ON audit_logs (entity_type, entity_id)');
|
|
$this->addSql('CREATE INDEX idx_audit_created ON audit_logs (created_at)');
|
|
$this->addSql('CREATE INDEX idx_audit_affected_date ON audit_logs (affected_date)');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
$this->addSql('DROP TABLE audit_logs');
|
|
}
|
|
}
|