<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class TaskInc64155 extends AbstractMigration
{
    public function up(): void
    {

        $rs = $this->fetchAll(<<<SQL
        SELECT sp.id FROM seguro.proponentes_restricoes_tecnicas AS spr INNER JOIN seguro.proponentes AS sp ON sp.id = spr.id_proponente LEFT JOIN seguro.proponentes_restricoes_tecnicas_propostas AS sprp ON sprp.id_proponente_restricao_tecnica = spr.id WHERE (sp.fl_restricao IS FALSE)
SQL);

        foreach ($rs as $row) {
            $this->execute("
                UPDATE seguro.proponentes
                SET fl_restricao = TRUE WHERE id = {$row['id']}
            ");
        }
    }

    public function down(): void
    {

    }
}
