<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

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

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