### A. Convert Doctrine array type to json type

1. Change type from Types::ARRAY to Types::JSON in the entity
2. Génerate the migration
2. (bis) generate a migration altering array types to json types
   When having this file, keep only lines containing `DC2Type` in a scratch file.
   Then in phpstorm, replace function, use regex in find:
   `.+?TABLE (\w+).+(CHANGE ((\w)+).+?COMMENT \\\'\(DC2Type:json\)).+`
   with replace pattern:
   `'$1' => ['$3']`
   Then replace all, this should generate a php associative array with table & columns for use in following script.

3. In the migration file, in the up() method, add the following code BEFORE the change the type of the field:
```php
public function Up(Schema $schema): void
{

    $tables = ['table_name']; // EDIT THIS LINE
    $columns = ['column_name']; // EDIT THIS LINE

    for ($i = 0; $i < count($tables); $i++) {
        $table = $tables[$i];
        $column = $columns[$i];

        foreach ($this->connection->fetchAllAssociative('SELECT * FROM ' . $table) as $row) {
            $convertedValue = ArrayToJsonHelper::convertArrayToJson($row[$column]);
            $this->addSql(
                'UPDATE tesst SET aaa = :new_value WHERE id = :id',
                array(
                    'new_value' => $convertedValue,
                    'id' => $row['id']
                )
            );
        }
    }

    // ADD THE CODE ABOVE THE LINES BELOW

    // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE table_name CHANGE column_name column_name JSON NOT NULL');
}
```

4. In the migration file, in the down() method, add the following code AFTER the change the type of the field:
```php
public function Down(Schema $schema): void
{
    // this down() migration is auto-generated, please modify it to your needs
    $this->addSql('ALTER TABLE tesst CHANGE aaa aaa LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\'');

    // ADD THE CODE BELOW THE LINES ABOVE

    $tables = ['table_name']; // EDIT THIS LINE
    $columns = ['column_name']; // EDIT THIS LINE

    for ($i = 0; $i < count($tables); $i++) {
        $table = $tables[$i];
        $column = $columns[$i];

        foreach ($this->connection->fetchAllAssociative('SELECT * FROM ' . $table) as $row) {
            $convertedValue = ArrayToJsonHelper::convertJsonToArray($row[$column]);
            $this->addSql(
                'UPDATE tesst SET aaa = :new_value WHERE id = :id',
                array(
                    'new_value' => $convertedValue,
                    'id' => $row['id']
                )
            );
        }
    }
}
```****