<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

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

            $builder = $this->getQueryBuilder();
            $builder->update('seguro.propostas_endosso')
                    ->set('fl_proposta_vigente', 'TRUE')
                    ->where(['id_proposta' => 1090295, 'id_endosso' => 866789])
                    ->execute();
        }
    }

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

            $builder = $this->getQueryBuilder();
            $builder->update('seguro.propostas_endosso')
                    ->set('fl_proposta_vigente', 'TRUE')
                    ->where(['id_proposta' => 1105722, 'id_endosso' => 866789])
                    ->execute();
        }
    }
}
