New SessionAuditLog (mirrors AppointmentEvent): session FK, field, operation (create/update/delete), old_value/new_value, actor id+name, note, created_at. Repository saves and lists a session's history (newest first, array hydration). Migration creates the table. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
32 lines
1.4 KiB
PHP
32 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
/**
|
|
* Auto-generated Migration: Please modify to your needs!
|
|
*/
|
|
final class Version20260717113519 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Add session_audit_logs table (financial/service change audit trail)';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->addSql('CREATE TABLE session_audit_logs (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) NOT NULL, field VARCHAR(40) NOT NULL, operation VARCHAR(10) NOT NULL, old_value LONGTEXT DEFAULT NULL, new_value LONGTEXT DEFAULT NULL, actor_user_id INT DEFAULT NULL, actor_name VARCHAR(191) DEFAULT NULL, note VARCHAR(191) DEFAULT NULL, created_at INT NOT NULL, session_id INT NOT NULL, UNIQUE INDEX UNIQ_36B92303D17F50A6 (uuid), INDEX IDX_36B92303613FECDF (session_id), INDEX idx_session_audit_session (session_id, created_at), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
|
$this->addSql('ALTER TABLE session_audit_logs ADD CONSTRAINT FK_36B92303613FECDF FOREIGN KEY (session_id) REFERENCES patient_sessions (id) ON DELETE CASCADE');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
$this->addSql('ALTER TABLE session_audit_logs DROP FOREIGN KEY FK_36B92303613FECDF');
|
|
$this->addSql('DROP TABLE session_audit_logs');
|
|
}
|
|
}
|