<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class Task2210071239 extends AbstractMigration
{
    public function up(): void
    {
        $row = $this->fetchRow('SELECT id FROM seguro.propostas WHERE id = 801617');
        if ($row['id']) {
            $this->execute("SELECT manutencao.anular_endosso(801617,213)");
            $this->execute("update seguro.propostas_endosso set fl_proposta_vigente = true where id_proposta = 760505");
            $this->execute("update seguro.propostas_endosso set fl_proposta_vigente = false where id_proposta = 801616");
        }
    }

    public function down(): void
    {
        $row = $this->fetchRow('SELECT id FROM seguro.propostas WHERE id = 801617');
        if ($row['id']) {
            $this->execute("SELECT seguro.ativa_proposta_status(801617,8)");
        }
    }
}
