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'); } }