<?php
declare(strict_types=1);
namespace Application\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241017154334 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$columns = [
['legal_entity_contract', 'file_path'],
['legal_entity_contract', 'legacy_file_path'],
['legal_entity_contract_custom_template', 'path'],
['legal_entity_questionnaire_benzene', 'file_path'],
['legal_entity_questionnaire_benzene', 'upload_path'],
];
foreach ($columns as $attempt) {
[$table, $column] = $attempt;
$sql = sprintf('SELECT id, `%1$s` AS value FROM `%2$s` WHERE `%1$s` LIKE ?', $column, $table);
$param = '/home/forge/www.siefspace.eu/releases/%';
$stmt = $this->connection->executeQuery($sql, [$param]);
foreach ($stmt->iterateAssociative() as $record) {
/** @var array{id: int, value: string} $record */
$array = explode('/', $record['value']);
array_splice($array, 4, 2);
$update = implode('/', $array);
unset($array);
$this->addSql("UPDATE `$table` SET `$column` = ? WHERE id = ?", [$update, $record['id']]);
}
}
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
}
}