<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class TaskInc67368 extends AbstractMigration
{
    public function up(): void
    {
        $row = $this->fetchRow('SELECT id FROM seguro.propostas WHERE id = 1106375');
        if ($row['id']) {
            $builder = $this->getQueryBuilder();
            $builder->update('seguro.propostas_endosso')
                    ->set('fl_proposta_vigente', 'TRUE')
                    ->where(['id_endosso' => 873503, 'id_proposta' => 1099453])
                    ->execute();
            $builder = $this->getQueryBuilder();
            $builder->update('seguro.propostas_endosso')
                    ->set('fl_proposta_vigente', 'FALSE')
                    ->where(['id_endosso' => 873503, 'id_proposta' => 1106375])
                    ->execute();
        }
    }

    public function down(): void
    {
        $row = $this->fetchRow('SELECT id FROM seguro.propostas WHERE id = 1106375');
        if ($row['id']) {
            $builder = $this->getQueryBuilder();
            $builder->update('seguro.propostas_endosso')
                    ->set('fl_proposta_vigente', 'FALSE')
                    ->where(['id_endosso' => 873503, 'id_proposta' => 1099453])
                    ->execute();
            $builder = $this->getQueryBuilder();
            $builder->update('seguro.propostas_endosso')
                    ->set('fl_proposta_vigente', 'TRUE')
                    ->where(['id_endosso' => 873503, 'id_proposta' => 1106375])
                    ->execute();
        }
    }
}
