<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

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

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